This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
EDT/ipad/module/ph.php
T
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

1269 lines
50 KiB
PHP

<?php
//-------------------------------排行榜
header("Content-type: text/html; charset=utf-8");
$page_num=10;
$uid=check_cookie_jxs();
$json_data="{";
if(THIS_IN!="edt_ipad")
exit("错误的访问!");
$msg_client=get_db_msg("select * from ".$table_pre."client where id='".$uid."'");
//
$face=$msg_client["face"];
$ph_ms=get_set("ph_ms");
$arr_ph_ms=explode(",",$ph_ms);
$sys_size_num=get_max_size_num();
$xh_ms=get_set("xh_ms");
//取得选项
$arr_select_no=array();
$arr_select_title=array();
$q="select no,title from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and flag_bd='n' and no<>'sx' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$arr_select_no[]=$m["no"];
$arr_select_title[]=$m["title"];
}
$con="";
for($i=0;$i<count($arr_select_no);$i++){
$v="s_".$arr_select_no[$i];
if($$v)
$con.=" and ".$arr_select_no[$i]."='".$$v."'";
}
if($s_qy && $s_qy!="-all-")
$con.=" and qy='".$s_qy."'";
//饰品款条件
if($s_is_sp=="n"){
$con1.=" and is_sp<>'y'";
$con.=" and is_sp<>'y'";
}else if($s_is_sp=="y"){
$con1.=" and is_sp='y'";
$con.=" and is_sp='y'";
}
$json_data.="\"face\":\"".$face."\",";
$json_data.="\"last_path\":\"".$last_path."\",";
//if($face==2) $face=3;
$num_my=$money_my=$money1="";
//http://47.99.153.58/edt7/ipad/?_m=ph&page=1&khid=5&_a=get_new
//http://localhost/edt7/ipad/?_m=ph&page=1&khid=2&_a=get_new&ms=2
//童装
if($child_sizegroup_title){
$tmp=get_db_msg("select id from ".$table_pre."keyword where cate='size' and title='".$child_sizegroup_title."' limit 0,1");
$child_sizegroup_id=$tmp["id"];
}else{
$child_sizegroup_id=0;
}
$is_sy=get_set("is_sy");
$json_data.="\"username\":\"".$msg_client["username"]."\",";
$json_data.="\"is_sy\":\"".$is_sy."\",";
switch($face){
case "1":
//全国排名
$arr_ph_ms=array("ph_dk|100","ph_ds|200");
$arr_op_ph_ms=array();
for($i=0;$i<count($arr_ph_ms);$i++){
$tmp=explode("|",$arr_ph_ms[$i]);
if($i==0){
$default_ph_ms=$tmp[0];
$default_ph_num=$tmp[1];
}
$arr_op_ph_ms[$tmp[0]]=d_translate($tmp[0]);
}
$s_ph_ms=$s_ph_ms?$s_ph_ms:$default_ph_ms;
//
for($i=0;$i<count($arr_ph_ms);$i++){
$tmp=explode("|",$arr_ph_ms[$i]);
if($s_ph_ms==$tmp[0])
$ph_num=$tmp[1];
}
$s_ph_num=$s_ph_ms?$ph_num:$default_ph_num;
$s_ph_num=$s_ph_num>0?$s_ph_num:0;
if($s_ph_ms=="ph_ds"){
$con_group_by="no,color";
$hj_colspan=5;
}else{
$con_group_by="no";
$hj_colspan=5;
}
$kh_ph_num=get_set("kh_ph_num");
$kh_ph_num=$kh_ph_num>0?$kh_ph_num:10;
$s_order=$s_order?$s_order:"num";
$s_desc=$s_desc?$s_desc:"d1";
//$content_search.="<input name=\"s_kh\" onchange=\"tj.submit();\" style=\"width:80px;height:22px;\" value=\"".$s_kh."\" placeholder=\"输入款号\"> ";
//排行模式
if(count($arr_ph_ms)>1){
$content_search.="<select name=\"s_ph_ms\" onchange=\"tj.submit();\" style=\"height:30px;\">".get_main_op($arr_op_ph_ms,$s_ph_ms)."</select> ";
}
//区域
$op="";
$q="select * from ".$table_pre."client where face='9' and deep=1 order by ord";
$r=$db->query($q);
$i=0;
$arr_op=array();
$arr_op[""]="区域过滤";
while($m=$db->fetch_array($r)){$op.="<option value=\"".$m["id"]."\"";
$arr_op[$m["id"]]=$m["title"];
$i++;
}
$i1=0;
//排行模式
if(count($arr_ph_ms)>1){
$search_select_no[$i1]="s_ph_ms";
$search_select_op[$i1]=$arr_op_ph_ms;
$i1++;
}
//区域选项
if($i>0){
$search_select_no[$i1]="s_qy";
$search_select_op[$i1]=$arr_op;
$i1++;
}
//选项前面
$select_qm="";
$arr_sz=array();
for($i=0;$i<count($search_select_no);$i++){
$tmp="";
foreach($search_select_op[$i] as $key=>$value){
$tmp.="{\"no\":\"".$key."\",\"title\":\"".$value."\"},";
$arr_sz[$i]=$value;
}
$tmp=deel_end($tmp);
$var=$search_select_no[$i];
$select_qm.="{\"no\":\"".$search_select_no[$i]."\",\"title\":\"".$search_select_op[$i][0]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
$select_qm=deel_end($select_qm);
$json_data.="\"select_qm\":[".$select_qm."],";
//取得定制选项
$select_dz="";
for($i=0;$i<count($arr_select_no);$i++){
//取得选项
$tmp="";
$r1=$db->query("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);
$var="s_".$arr_select_no[$i];
$select_dz.="{\"no\":\"".$arr_select_no[$i]."\",\"title\":\"".$arr_select_title[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
$select_dz=deel_end($select_dz);
$json_data.="\"select_dz\":[".$select_dz."],";
$search_select_op=$search_select_no=array();
$i1=0;
$search_select_no[$i1]="s_desc";
$search_select_op[$i1]=array("d1"=>"正序","d2"=>"倒序");
$i1++;
$search_select_no[$i1]="s_order";
$search_select_op[$i1]=array("num"=>"数量排序","je"=>"金额排序");
$i1++;
$order_ph=($s_desc=="d1")?" desc":"";
//选项后
$select_hm="";
$arr_sz=array();
for($i=0;$i<count($search_select_no);$i++){
$tmp="";
foreach($search_select_op[$i] as $key=>$value){
$tmp.="{\"no\":\"".$key."\",\"title\":\"".$value."\"},";
$arr_sz[$i]=$value;
}
$tmp=deel_end($tmp);
$var=$search_select_no[$i];
$select_hm.="{\"no\":\"".$search_select_no[$i]."\",\"title\":\"".$search_select_op[$i][0]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
$select_hm=deel_end($select_hm);
$json_data.="\"select_hm\":[".$select_hm."],\"jzsj\":\"截止".date("m-d日H:i")."\",\"s_kh\":\"".$s_kh."\",\"s_yph\":\"".$s_yph."\",";
if($s_ph_ms=="ph_ds"){
$con_kc="";
foreach($sys_color_zd as $k1 => $v1){
$v="s_color_".$k1;
if($$v)
$con_kc.=" and kc.".$k1."='".$$v."'";
//$content_search.="<select name=\"".$v."\" onchange=\"tj.submit();\" style=\"width:80px;height:30px;\"><option value=''>-".$v1."-</option>".op_select_cate_color($k1,$$v)."</select> ";
}
}
//
$content_search.="<select name=\"s_order\" onchange=\"tj.submit();\" style=\"width:60px;height:30px;\">".get_main_op(array("num"=>"数量排序","je"=>"金额排序"),$s_order)."</select> 截止".date("m-d日H:i");
//
$content="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"#000000\" class=\"fix1\"><thead><tr><td width=\"50\" height=\"25\" align=\"center\" class=\"thead\"><strong>次序</strong></td><td width=\"60\" height=\"25\" align=\"center\" class=\"thead\"><strong>全国排名</strong></td><td width=\"60\" align=\"center\" class=\"thead\"><strong>".d_translate("xh")."</strong></td><td align=\"center\" class=\"thead\"><strong>款号</strong></td>";
$json_data.="\"table_top\":[\"|次序\",\"全国排名\",\"this|款号\",";
if($s_ph_ms=="ph_ds"){
$content.="<td align=\"center\" class=\"thead\"><strong>颜色</strong></td>";
$group_by_ph1="no,color";
$json_data.="\"颜色\",";
}else{
//取得色总排名
$arr_ph_color=array();
$q1="select sum(num) 'num',sum(je) 'je' from ".$table_pre."ph group by no,color order by ".$s_order." desc";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$arr_ph_color[]=$m1[$s_order];
}
$content.="<td align=\"center\" class=\"thead\"><strong>颜色/色总排名</strong></td>";
$json_data.="\"颜色/色总排名\",";
$group_by_ph1="no";
}
//取得全国排名数组
$arr_ph=array();
$q1="select sum(num) 'num',sum(je) 'je',".$group_by_ph1." from ".$table_pre."ph group by ".$group_by_ph1." order by ".$s_order." ".$order_ph."";
$r1=$db->query($q1);
$arr_qgdl=array();
while($m1=$db->fetch_array($r1)){
$arr_ph[]=$m1[$s_order];
if($s_ph_ms=="ph_ds"){
$arr_qgdl[$m1["no"]."_".$m1["color"]]=$m1["num"];
}else{
$arr_qgdl[$m1["no"]]=$m1["num"];
}
}
//$content.="<td align=\"center\" class=\"thead\" width=\"80\"><strong>".d_translate("dpj")."</strong></td><td align=\"center\" class=\"thead\" width=\"80\"><b>件数</b></td><td align=\"center\" class=\"thead\" width=\"80\"><b>".d_translate("dpje")."</b></td></tr></thead>";
if($sys_ver_hy=="xz"){
$json_data.="\"".d_translate("dpj")."\",\"件数\",\"箱数\",\"".d_translate("dpje")."\"],";
}else{
$json_data.="\"".d_translate("dpj")."\",\"件数\",\"".d_translate("dpje")."\"],";
}
$json_data1="";
$con1="";
if($s_kh)
$con1.=" and no like '%".$s_kh."%'";
if($s_yph){
if($xh_ms=="2"){
$tkh=get_db_msg("select * from ".$table_pre."kh_xh where xh='".$s_yph."'");
$con1.=" and no='".$tkh["kh"]."' and color='".$tkh["color"]."'";
}else{
$tkh=get_db_msg("select * from ".$table_pre."kh where xh='".$s_yph."'");
$con1.=" and no='".$tkh["no"]."'";
}
}
//if($s_qy)
//$con1.=" and (qy='".$s_qy."')";
for($i=0;$i<count($arr_select_no);$i++){
$v="s_".$arr_select_no[$i];
if($$v)
$con1.=" and ".$arr_select_no[$i]."='".$$v."'";
}
//$q1="select sum(num) 'num',sum(je) 'je',p.iid,p.color from ".$table_pre."ph p left join ".$table_pre."kh_color kc on kc.iid=p.iid and kc.color=p.color where p.id>0 ".$con1.$con_kc." group by ".$con_group_by." order by ".$s_order." desc";
$q1="select sum(num) 'num',sum(je) 'je',iid,color from ".$table_pre."ph where id>0 ".$con1." group by ".$con_group_by." order by ".$s_order." ".$order_ph."";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$page_total_num++;
}
if(!$page) $page=1;
$pages=ceil($page_total_num/$page_num);
$limit_con=($page-1)*$page_num;
$count=$limit_con;
//$q="select sum(num) 'num',sum(je) 'je',p.iid,p.color from ".$table_pre."ph p left join ".$table_pre."kh_color kc on kc.iid=p.iid and kc.color=p.color where p.id>0 ".$con1.$con_kc." group by ".$con_group_by." order by ".$s_order." desc limit ".$limit_con.",".$page_num."";
if($s_qy){
$q="select sum(case when qy='".$s_qy."' then num else 0 end) 'num' ,sum(case when qy='".$s_qy."' then je else 0 end) 'je',iid,color from ".$table_pre."ph where id>0 ".$con1." group by ".$con_group_by." order by ".$s_order." ".$order_ph." limit ".$limit_con.",".$page_num."";
}else{
$q="select sum(num) 'num',sum(je) 'je',iid,color from ".$table_pre."ph where id>0 ".$con1." group by ".$con_group_by." order by ".$s_order." ".$order_ph." limit ".$limit_con.",".$page_num."";
}
//echo $q."<br>";
$r=$db->query($q);
$total_num=$total_money=$count_yd=0;
while($m=$db->fetch_array($r)){
$c1=($count%2)?"td1":"td2";
$list=$count+1;
$m1=get_db_msg("select id,no,main_pic,color,xh,size_group from ".$table_pre."kh where id='".$m["iid"]."'");
if($sys_ver_hy=="xz"){
$xs=0;
if($s_ph_ms=="ph_ds"){
$tmpxs=get_db_msg("select sum(xs) xs from ".$table_pre."order_pm where iid='".$m["iid"]."' and color='".$m["color"]."'");
$xs=$tmpxs["xs"];
}else{
$tmpxs=get_db_msg("select sum(xs) xs from ".$table_pre."order_pm where iid='".$m["iid"]."' ");
$xs=$tmpxs["xs"];
}
}
$num=$m["num"];
if($num>0)
$count_yd++;
$total_num+=$num;
$money=$m["je"];
$total_money+=$money;
//图片获取规则
if($s_ph_ms=="ph_ds"){
$pic=get_kh_color_picture($m1["no"],$m["color"],$flag_pad_offline);
$pic2=get_kh_color_picture_big($m1["no"],$m["color"]);
}else{
$pic=get_kh_picture($m1["no"],$m1["main_pic"],$m1["color"],$flag_pad_offline);
$pic="'".$pic."' ".str_replace("\"","'",out_good_pic_set($pic,80,80))." border=0";
$pic2=get_kh_picture_big($m1["no"],$m1["main_pic"],$m1["color"],$flag_pad_offline);
}
if($s_ph_ms=="ph_ds"){
$dl=$arr_qgdl[$m1["no"]."_".$m["color"]];
}else{
$dl=$arr_qgdl[$m1["no"]];
}
$pm=get_main_key($arr_ph,$dl)+1;
if($s_ph_ms=="ph_ds"){
//到色
$tmp_arr=explode(",",$m1["color"]);
$color_flag="";
if(count($tmp_arr)>1){
for($i1=0;$i1<count($tmp_arr);$i1++){
$cls1=($tmp_arr[$i1]==$m["color"])?"color:red;font-weight:bold;":"";
$color_flag.="<span style=\"".$cls1."\">".$tmp_arr[$i1]."-".get_cate_title_no("color",$tmp_arr[$i1])."</span>,";
}
if($color_flag)
$color_flag=" (".substr($color_flag,0,-1).")";
}
$content.="<tr><td class=\"".$c1."\" height=\"20\">".$list."</td><td class=\"".$c1."\">".$pm."</td><td class=\"".$c1."\">".get_kh_xh($m1,$m["color"])."</td><td class=\"".$c1."\"><a href=\"javascript:show_kh_pic('".$m1["no"]."','".$pic."')\" onmouseover=\"show_kh_pic('".$m1["no"]."','".$pic."')\">".$m1["no"].$color_flag."</a></td>";
$content.="<td class=\"".$c1."\">".$m["color"]."-".get_cate_title_no("color",$m["color"])."</td>";
$href_color="&color=".$m["color"];
$json_data1.="[\"".$m1["id"]."\",\"".$list."\",\"pma|".$pm."\",\"this|".get_kh_xh($m1,$m["color"])."|".$m1["id"]."|".$pic."|".$m1["no"]."|".$pic2."\",";
$json_data1.="\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\",";
}else{
$json_data1.="[\"".$m1["id"]."\",\"".$list."\",\"pma|".$pm."\",\"this|".get_kh_xh($m1,$m["color"])."|".$m1["id"]."|".$pic."|".$m1["no"]."|".$pic2."\",";
$content.="<tr><td class=\"".$c1."\" height=\"20\">".$list."</td><td class=\"".$c1."\">".$pm."</td><td class=\"".$c1."\">".get_kh_xh($m1)."</td><td class=\"".$c1."\"><a href=\"javascript:show_kh_pic('".$m1["no"]."','".$pic."')\" onmouseover=\"show_kh_pic('".$m1["no"]."','".$pic."')\">".$m1["no"]."</a></td>";
//取得颜色
$q2="select color,sum(num) 'num',sum(je) 'je' from ".$table_pre."ph where iid='".$m["iid"]."' group by color order by ".$s_order." desc";
$r2=$db->query($q2);
$str_color="";
while($m2=$db->fetch_array($r2)){
$str_color.=$m2["color"]."-".get_cate_title_no("color",$m2["color"])." / ".(get_main_key($arr_ph_color,$m2[$s_order])+1)."<br>";
}
if($str_color)
$str_color=substr($str_color,0,-4);
$content.="<td class=\"".$c1."\">".$str_color."</td>";
$json_data1.="\"".$str_color."\",";
$href_color="";
}
if($s_ph_ms=="ph_ds")
$colors=$m["color"];
else
$colors="";
$content.="<td class=\"".$c1."\" align=\"right\"><a href=\"".$_SERVER[PHP_SELF]."?_m=".$_m."&_a=view_order&id=".$m1["id"].$href_color."&window=new\" target=\"_blank\"><span class='bb_link'>".$m["num"]."</span></a></td>";
$content.="<td class=\"".$c1."\" align=\"right\">".deel_num($m["je"])."</td></tr>";
if($sys_ver_hy=="xz"){
$json_data1.="\"".get_price_dp($uid,$m1["id"])."\",\"jianshu|".$m["num"]."|".$m1["no"]."|".$colors."\",\"".deel_num($xs)."\",\"".deel_num($m["je"])."\"],";
}else{
if($m1["size_group"]==$child_sizegroup_id){
$qa="select * from ".$table_pre."size_bx where no='".$m1["no"]."' order by id";
$ra=$db->query($qa);
$str_tzbx="";
while($ma=$db->fetch_array($ra)){
$str_tzbx.=$ma["bx"].":".$ma["price"]."<br>";
}
$json_data1.="\"".$str_tzbx."\",\"jianshu|".$m["num"]."|".$m1["no"]."|".$colors."\",\"".deel_num($m["je"])."\"],";
}else{
$json_data1.="\"".get_price_dp($uid,$m1["id"])."\",\"jianshu|".$m["num"]."|".$m1["no"]."|".$colors."\",\"".deel_num($m["je"])."\"],";
}
}
$count++;
}
$json_data.="\"pages\":\"".$pages."\",\"table_mid\":[".substr($json_data1,0,-1)."],";
$content.="</table></td></tr></table>";
break;
case "2":
if($arr_ph_ms[0]!=""){
$json_data.="\"is_ph_state\":\"ok\",";
$arr_op_ph_ms=array();
for($i=0;$i<count($arr_ph_ms);$i++){
$tmp=explode("|",$arr_ph_ms[$i]);
if($i==0){
$default_ph_ms=$tmp[0];
$default_ph_num=$tmp[1];
}
$arr_op_ph_ms[$tmp[0]]=d_translate($tmp[0]);
}
$s_ph_ms=$s_ph_ms?$s_ph_ms:$default_ph_ms;
//
for($i=0;$i<count($arr_ph_ms);$i++){
$tmp=explode("|",$arr_ph_ms[$i]);
if($s_ph_ms==$tmp[0])
$ph_num=$tmp[1];
}
$s_ph_num=$s_ph_ms?$ph_num:$default_ph_num;
$s_ph_num=$s_ph_num>0?$s_ph_num:0;
if($s_ph_ms=="ph_ds"){
$con_group_by="no,color";
$hj_colspan=5;
}else{
$con_group_by="no";
$hj_colspan=5;
}
$kh_ph_num=get_set("kh_ph_num");
$kh_ph_num=$kh_ph_num>0?$kh_ph_num:10;
$s_order=$s_order?$s_order:"num";
//区域
$op="";
$q="select id,title from ".$table_pre."client where face='9' order by title";
$r=$db->query($q);
$i=0;
$arr_op=array();
$arr_op[""]="区域过滤";
while($m=$db->fetch_array($r)){
$arr_op[$m["id"]]=$m["title"];
$i++;
}
$i1=0;
//排行模式
if(count($arr_ph_ms)>1){
$search_select_no[$i1]="s_ph_ms";
$search_select_op[$i1]=$arr_op_ph_ms;
$i1++;
}
//区域选项
if($i>0){
$search_select_no[$i1]="s_qy";
$search_select_op[$i1]=$arr_op;
$i1++;
}
//选项前面
$select_qm="";
$arr_sz=array();
for($i=0;$i<count($search_select_no);$i++){
$tmp="";
foreach($search_select_op[$i] as $key=>$value){
$tmp.="{\"no\":\"".$key."\",\"title\":\"".$value."\"},";
$arr_sz[$i]=$value;
}
$tmp=deel_end($tmp);
$var=$search_select_no[$i];
$select_qm.="{\"no\":\"".$search_select_no[$i]."\",\"title\":\"".$search_select_op[$i][0]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
$select_qm=deel_end($select_qm);
$json_data.="\"select_qm\":[".$select_qm."],\"select_hm\":[],";
//取得定制选项
$select_dz="";
for($i=0;$i<count($arr_select_no);$i++){
//取得选项
$tmp="";
$r1=$db->query("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);
$var="s_".$arr_select_no[$i];
$select_dz.="{\"no\":\"".$arr_select_no[$i]."\",\"title\":\"".$arr_select_title[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
$select_dz=deel_end($select_dz);
$json_data.="\"select_dz\":[".$select_dz."],";
//
$content="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"#000000\" class=\"fix1\"><thead><tr><td width=\"50\" height=\"25\" align=\"center\" class=\"thead\"><strong>次序</strong></td><td width=\"60\" height=\"25\" align=\"center\" class=\"thead\"><strong>全国排名</strong></td><td width=\"60\" align=\"center\" class=\"thead\"><strong>".d_translate("xh")."</strong></td><td align=\"center\" class=\"thead\"><strong>款号</strong></td>";
$json_data.="\"table_top\":[\"|次序\",\"全国排名\",\"this|款号\",";
//如果启用多品牌
if($s_brand && $is_brand=="y")
$con_brand1=" where brand='".$s_brand."'";
else
$con_brand1="";
//
if($s_ph_ms=="ph_ds"){
$content.="<td align=\"center\" class=\"thead\"><strong>颜色</strong></td>";
$json_data.="\"颜色\",";
$group_by_ph1="no,color";
}else{
//取得色总排名
$arr_ph_color=array();
$q1="select sum(num) 'num',sum(je) 'je' from ".$table_pre."ph ".$con_brand1." group by no,color order by ".$s_order." desc";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$arr_ph_color[]=$m1[$s_order];
}
$content.="<td align=\"center\" class=\"thead\"><strong>颜色/色总排名</strong></td>";
$json_data.="\"颜色/色总排名\",";
$group_by_ph1="no";
}
//取得全国排名数组
$arr_ph=array();
$ctt=1;
$q1="select sum(num) 'num',sum(je) 'je',".$group_by_ph1." from ".$table_pre."ph ".$con_brand1." group by ".$group_by_ph1." order by ".$s_order." desc";
$r1=$db->query($q1);
$arr_qgdl=array();
while($m1=$db->fetch_array($r1)){
//$arr_ph[]=$m1[$s_order];
/*if($s_ph_ms=="ph_ds"){
$arr_qgdl[$m1["no"]."_".$m1["color"]]=$ctt;
}else{
$arr_qgdl[$m1["no"]]=$ctt;
}
$ctt++;*/
$arr_ph[]=$m1[$s_order];
if($s_ph_ms=="ph_ds"){
$arr_qgdl[$m1["no"]."_".$m1["color"]]=$m1["num"];
}else{
$arr_qgdl[$m1["no"]]=$m1["num"];
}
}
$content.="<td align=\"center\" class=\"thead\" width=\"80\"><strong>".d_translate("dpj")."</strong></td></tr></thead>";
$json_data.="\"".d_translate("dpj")."\"],";
$con1="";
if($s_no)
$con1.="no like '%".$s_no."%' and ";
//if($s_qy)
//$con1.="qy='".$s_qy."' and ";
for($i=0;$i<count($arr_select_no);$i++){
$v="s_".$arr_select_no[$i];
if($$v)
$con1.=$arr_select_no[$i]."='".$$v."' and ";
}
if($con1)
$con1="where ".substr($con1,0,-4);
$json_data1="";
//$q1="select sum(num) 'num',sum(je) 'je',iid,color from ".$table_pre."ph ".$con1." group by ".$con_group_by." order by ".$s_order." desc limit 0,".$s_ph_num;
$q1="select sum(num) 'num',sum(je) 'je',iid,color from ".$table_pre."ph ".$con1." group by ".$con_group_by." order by ".$s_order." desc";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$page_total_num++;
}
if(!$page) $page=1;
$pages=ceil($page_total_num/$page_num);
$limit_con=($page-1)*$page_num;
//$q="select sum(num) 'num',sum(je) 'je',iid,color from ".$table_pre."ph ".$con1." group by ".$con_group_by." order by ".$s_order." desc limit ".$limit_con.",".$page_num;
if($s_qy){
$q="select sum(case when qy='".$s_qy."' then num else 0 end) 'num' ,sum(case when qy='".$s_qy."' then je else 0 end) 'je',iid,color from ".$table_pre."ph ".$con1." group by ".$con_group_by." order by ".$s_order." desc limit ".$limit_con.",".$page_num."";
}else{
$q="select sum(num) 'num',sum(je) 'je',iid,color from ".$table_pre."ph ".$con1." group by ".$con_group_by." order by ".$s_order." desc limit ".$limit_con.",".$page_num."";
}
//echo $q."<br>";
$r=$db->query($q);
$total_num=$total_money=$count_yd=0;
$count=$limit_con;
while($m=$db->fetch_array($r)){
$m1=get_db_msg("select * from ".$table_pre."kh where id='".$m["iid"]."'");
if($s_ph_ms=="ph_ds"){
$dl=$arr_qgdl[$m1["no"]."_".$m["color"]];
}else{
$dl=$arr_qgdl[$m1["no"]];
}
//$pm=$dl;
$pm=get_main_key($arr_ph,$dl)+1;
//if($pm<=$s_ph_num){
$c1=($count%2)?"td1":"td2";
$list=$count+1;
$num=$m["num"];
if($num>0)
$count_yd++;
$total_num+=$num;
$money=$m["je"];
$total_money+=$money;
//图片获取规则
if($s_ph_ms=="ph_ds"){
$pic=get_kh_color_picture($m1["no"],$m["color"],$flag_pad_offline);
$pic2=get_kh_color_picture_big($m1["no"],$m["color"]);
}else{
$pic=get_kh_picture($m1["no"],$m1["main_pic"],$m1["color"],$flag_pad_offline);
$pic="'".$pic."' ".str_replace("\"","'",out_good_pic_set($pic,80,80))." border=0";
$pic2=get_kh_picture_big($m1["no"],$m1["main_pic"],$m1["color"],$flag_pad_offline);
}
$json_data1.="[\"".$m1["id"]."\",\"".$list."\",\"pma|".$pm."\",\"this|".get_kh_xh($m1,$m["color"])."|".$m1["id"]."|".$pic."|".$m1["no"]."|".$pic2."\",";
if($s_ph_ms=="ph_ds"){
$json_data1.="\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\",";
}else{
//取得颜色
$q2="select color,sum(num) 'num',sum(je) 'je' from ".$table_pre."ph where iid='".$m["iid"]."' group by color order by ".$s_order." desc";
$r2=$db->query($q2);
$str_color="color|";
while($m2=$db->fetch_array($r2)){
$str_color.=$m2["color"]."-".get_cate_title_no("color",$m2["color"])." / ".(get_main_key($arr_ph_color,$m2[$s_order])+1)."|";
}
if($str_color)
$str_color=substr($str_color,0,-1);
$json_data1.="\"".$str_color."\",";
}
if($m1["size_group"]==$child_sizegroup_id){
$qa="select * from ".$table_pre."size_bx where no='".$m1["no"]."' order by id";
$ra=$db->query($qa);
$str_tzbx="";
while($ma=$db->fetch_array($ra)){
$str_tzbx.=$ma["bx"].":".$ma["price"]."<br>";
}
$json_data1.="\"".$str_tzbx."\"],";
}else{
$json_data1.="\"".get_price_dp($uid,$m1["id"])."\"],";
}
$count++;
//}
}
$json_data.="\"pages\":\"".$pages."\",\"table_mid\":[".substr($json_data1,0,-1)."],";
}else{
$json_data.="\"is_ph_state\":\"nook\",";
$json_data.="\"pages\":\"0\",";
}
break;
case "3":
if($arr_ph_ms[0]!=""){
$json_data.="\"is_ph_state\":\"ok\",";
$arr_op_ph_ms=array();
for($i=0;$i<count($arr_ph_ms);$i++){
$tmp=explode("|",$arr_ph_ms[$i]);
if($i==0){
$default_ph_ms=$tmp[0];
$default_ph_num=$tmp[1];
}
$arr_op_ph_ms[$tmp[0]]=d_translate($tmp[0]);
}
$s_ph_ms=$s_ph_ms?$s_ph_ms:$default_ph_ms;
//
for($i=0;$i<count($arr_ph_ms);$i++){
$tmp=explode("|",$arr_ph_ms[$i]);
if($s_ph_ms==$tmp[0])
$ph_num=$tmp[1];
}
$s_ph_num=$s_ph_ms?$ph_num:$default_ph_num;
$s_ph_num=$s_ph_num>0?$s_ph_num:0;
if($s_ph_ms=="ph_ds"){
$con_group_by="no,color";
$hj_colspan=5;
}else{
$con_group_by="no";
$hj_colspan=5;
}
$kh_ph_num=get_set("kh_ph_num");
$kh_ph_num=$kh_ph_num>0?$kh_ph_num:10;
$s_order=$s_order?$s_order:"num";
//区域
$op="";
$q="select id,title from ".$table_pre."client where face='9' order by title";
$r=$db->query($q);
$i=0;
$arr_op=array();
$arr_op[""]="区域过滤";
while($m=$db->fetch_array($r)){
$arr_op[$m["id"]]=$m["title"];
$i++;
}
$i1=0;
//排行模式
if(count($arr_ph_ms)>1){
$search_select_no[$i1]="s_ph_ms";
$search_select_op[$i1]=$arr_op_ph_ms;
$i1++;
}
//区域选项
if($i>0){
$search_select_no[$i1]="s_qy";
$search_select_op[$i1]=$arr_op;
$i1++;
}
//选项前面
$select_qm="";
$arr_sz=array();
for($i=0;$i<count($search_select_no);$i++){
$tmp="";
foreach($search_select_op[$i] as $key=>$value){
$tmp.="{\"no\":\"".$key."\",\"title\":\"".$value."\"},";
$arr_sz[$i]=$value;
}
$tmp=deel_end($tmp);
$var=$search_select_no[$i];
$select_qm.="{\"no\":\"".$search_select_no[$i]."\",\"title\":\"".$search_select_op[$i][0]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
$select_qm=deel_end($select_qm);
$json_data.="\"select_qm\":[".$select_qm."],\"select_hm\":[],";
//取得定制选项
$select_dz="";
for($i=0;$i<count($arr_select_no);$i++){
//取得选项
$tmp="";
$r1=$db->query("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);
$var="s_".$arr_select_no[$i];
$select_dz.="{\"no\":\"".$arr_select_no[$i]."\",\"title\":\"".$arr_select_title[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
$select_dz=deel_end($select_dz);
$json_data.="\"select_dz\":[".$select_dz."],";
//
$content="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"#000000\" class=\"fix1\"><thead><tr><td width=\"50\" height=\"25\" align=\"center\" class=\"thead\"><strong>次序</strong></td><td width=\"60\" height=\"25\" align=\"center\" class=\"thead\"><strong>全国排名</strong></td><td width=\"60\" align=\"center\" class=\"thead\"><strong>".d_translate("xh")."</strong></td><td align=\"center\" class=\"thead\"><strong>款号</strong></td>";
$json_data.="\"table_top\":[\"|次序\",\"全国排名\",\"this|款号\",";
//如果启用多品牌
if($s_brand && $is_brand=="y")
$con_brand1=" where brand='".$s_brand."'";
else
$con_brand1="";
//
if($s_ph_ms=="ph_ds"){
$content.="<td align=\"center\" class=\"thead\"><strong>颜色</strong></td>";
$json_data.="\"颜色\",";
$group_by_ph1="no,color";
}else{
//取得色总排名
$arr_ph_color=array();
$q1="select sum(num) 'num',sum(je) 'je' from ".$table_pre."ph ".$con_brand1." group by no,color order by ".$s_order." desc";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$arr_ph_color[]=$m1[$s_order];
}
$content.="<td align=\"center\" class=\"thead\"><strong>颜色/色总排名</strong></td>";
$json_data.="\"颜色/色总排名\",";
$group_by_ph1="no";
}
//取得全国排名数组
$arr_ph=array();
$ctt=1;
$q1="select sum(num) 'num',sum(je) 'je',".$group_by_ph1." from ".$table_pre."ph ".$con_brand1." group by ".$group_by_ph1." order by ".$s_order." desc";
$r1=$db->query($q1);
$arr_qgdl=array();
while($m1=$db->fetch_array($r1)){
//$arr_ph[]=$m1[$s_order];
/*if($s_ph_ms=="ph_ds"){
$arr_qgdl[$m1["no"]."_".$m1["color"]]=$ctt;
}else{
$arr_qgdl[$m1["no"]]=$ctt;
}
$ctt++;*/
$arr_ph[]=$m1[$s_order];
if($s_ph_ms=="ph_ds"){
$arr_qgdl[$m1["no"]."_".$m1["color"]]=$m1["num"];
}else{
$arr_qgdl[$m1["no"]]=$m1["num"];
}
}
$content.="<td align=\"center\" class=\"thead\" width=\"80\"><strong>".d_translate("dpj")."</strong></td></tr></thead>";
$json_data.="\"".d_translate("dpj")."\"],";
$con1="";
if($s_no)
$con1.="no like '%".$s_no."%' and ";
//if($s_qy)
//$con1.="qy='".$s_qy."' and ";
for($i=0;$i<count($arr_select_no);$i++){
$v="s_".$arr_select_no[$i];
if($$v)
$con1.=$arr_select_no[$i]."='".$$v."' and ";
}
if($con1)
$con1="where ".substr($con1,0,-4);
$json_data1="";
$q1="select sum(num) 'num',sum(je) 'je',iid,color from ".$table_pre."ph ".$con1." group by ".$con_group_by." order by ".$s_order." desc limit 0,".$s_ph_num;
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$page_total_num++;
}
if(!$page) $page=1;
$pages=ceil($page_total_num/$page_num);
$limit_con=($page-1)*$page_num;
//$q="select sum(num) 'num',sum(je) 'je',iid,color from ".$table_pre."ph ".$con1." group by ".$con_group_by." order by ".$s_order." desc limit ".$limit_con.",".$page_num;
if($s_qy){
$q="select sum(case when qy='".$s_qy."' then num else 0 end) 'num' ,sum(case when qy='".$s_qy."' then je else 0 end) 'je',iid,color from ".$table_pre."ph ".$con1." group by ".$con_group_by." order by ".$s_order." desc limit ".$limit_con.",".$page_num."";
}else{
$q="select sum(num) 'num',sum(je) 'je',iid,color from ".$table_pre."ph ".$con1." group by ".$con_group_by." order by ".$s_order." desc limit ".$limit_con.",".$page_num."";
}
//echo $q."<br>";
$r=$db->query($q);
$total_num=$total_money=$count_yd=0;
$count=$limit_con;
while($m=$db->fetch_array($r)){
$m1=get_db_msg("select * from ".$table_pre."kh where id='".$m["iid"]."'");
if($s_ph_ms=="ph_ds"){
$dl=$arr_qgdl[$m1["no"]."_".$m["color"]];
}else{
$dl=$arr_qgdl[$m1["no"]];
}
//$pm=$dl;
$pm=get_main_key($arr_ph,$dl)+1;
if($pm<=$s_ph_num){
$c1=($count%2)?"td1":"td2";
$list=$count+1;
$num=$m["num"];
if($num>0)
$count_yd++;
$total_num+=$num;
$money=$m["je"];
$total_money+=$money;
//图片获取规则
if($s_ph_ms=="ph_ds"){
$pic=get_kh_color_picture($m1["no"],$m["color"],$flag_pad_offline);
$pic2=get_kh_color_picture_big($m1["no"],$m["color"]);
}else{
$pic=get_kh_picture($m1["no"],$m1["main_pic"],$m1["color"],$flag_pad_offline);
$pic="'".$pic."' ".str_replace("\"","'",out_good_pic_set($pic,80,80))." border=0";
$pic2=get_kh_picture_big($m1["no"],$m1["main_pic"],$m1["color"],$flag_pad_offline);
}
$json_data1.="[\"".$m1["id"]."\",\"".$list."\",\"pma|".$pm."\",\"this|".get_kh_xh($m1,$m["color"])."|".$m1["id"]."|".$pic."|".$m1["no"]."|".$pic2."\",";
if($s_ph_ms=="ph_ds"){
$json_data1.="\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\",";
}else{
//取得颜色
$q2="select color,sum(num) 'num',sum(je) 'je' from ".$table_pre."ph where iid='".$m["iid"]."' group by color order by ".$s_order." desc";
$r2=$db->query($q2);
$str_color="color|";
while($m2=$db->fetch_array($r2)){
$str_color.=$m2["color"]."-".get_cate_title_no("color",$m2["color"])." / ".(get_main_key($arr_ph_color,$m2[$s_order])+1)."|";
}
if($str_color)
$str_color=substr($str_color,0,-1);
$json_data1.="\"".$str_color."\",";
}
if($m1["size_group"]==$child_sizegroup_id){
$qa="select * from ".$table_pre."size_bx where no='".$m1["no"]."' order by id";
$ra=$db->query($qa);
$str_tzbx="";
while($ma=$db->fetch_array($ra)){
$str_tzbx.=$ma["bx"].":".$ma["price"]."<br>";
}
$json_data1.="\"".$str_tzbx."\"],";
}else{
$json_data1.="\"".get_price_dp($uid,$m1["id"])."\"],";
}
$count++;
}
}
$json_data.="\"pages\":\"".$pages."\",\"table_mid\":[".substr($json_data1,0,-1)."],";
}else{
$json_data.="\"is_ph_state\":\"nook\",";
$json_data.="\"pages\":\"0\",";
}
break;
case "4":
//-------------------------------------------------------------------------店铺角色
$is_spk=get_set("is_spk");
$con_spk=($is_spk=="y")?" and is_sp<>'y'":"";
if($_a=="get_new"){
//获取完成率和已订件数,传递参数khid
//完成率
//已订金额和件数
$tmp=get_db_msg("select sum(je) 'je',sum(jsje) 'jsje',sum(num) 'num' from ".$table_pre."order where ka<>'y'".$con_spk." and uid='".$uid."' and _key='".$_key."'");
$ydje=$tmp["je"];
$ydjsje=$tmp["jsje"];
$ydjs=$tmp["num"];
if($is_brand=="y"){
$tmp=get_db_msg("select sum(zb) 'zb',sum(zb_js) 'zb_js' from ".$table_pre."client_brand where cid='".$uid."'");
$zb1=$tmp["zb"]*10000;
$zb=deel_num($tmp["zb"]);
$zb_js=$tmp["zb_js"];
}else{
$zb1=$msg_login["zb"]*10000;
$zb=deel_num($msg_login["zb"]);
$zb_js=$msg_login["zb_js"];
}
$wcl=deel_bfb1($ydje,$zb1,1);
$wcl_js=deel_bfb1($ydjs,$zb_js,1);
if($khid){
$tmp=get_db_msg("select sum(num) 'num' from ".$table_pre."order where uid='".$uid."' and iid='".$khid."' and _key='".$_key."'");
$k_ydjs=$tmp["num"];
}else{
$k_ydjs=0;
}
//该款已订件数
$zb_client_show=get_set("zb_client_show");
$json_data.="\"ydjs\":\"".$k_ydjs."\",";
$json_data.="\"zb_client_show\":\"".$zb_client_show."\",";
//订货信息
$json_data.="\"order_num\":\"".$ydjs."\",\"order_je\":\"".$ydje."\",\"order_jsje\":\"".$ydjsje."\",";
//指标信息
$json_data.="\"zb_je\":\"".$zb."\",\"wcl_je\":\"".$wcl."\",\"zb_js\":\"".$zb_js."\",\"wcl_js\":\"".$wcl_js."\",";
if($khid && $ms=="1"){
$num_my=get_order_num_kh($khid);
$money1=get_order_je_kh($khid);
$money_my=deel_0($money1[0]);
//取得我的排行
$arr_my_ph_num=array();
$q1="select sum(num) 'num' from ".$table_pre."order where ka<>'y' and uid='".$uid."' group by no order by num desc";
//echo $q1."<br>";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$arr_my_ph_num[]=$m1["num"];
}
$arr_my_ph_num=array_unique($arr_my_ph_num);
if($num_my>0){
$ph_my2=get_main_key($arr_my_ph_num,$num_my);
$ph_my2++;
}else{
$ph_my2="";
}
}
if($khid && $ms=="2"){
//取得我的排行
$arr_my_ph_num=array();
$q1="select sum(num) 'num' from ".$table_pre."order where ka<>'y' and uid='".$uid."' group by no,color order by num desc";
//echo $q1."<br>";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$arr_my_ph_num[]=$m1["num"];
}
$arr_my_ph_num=array_unique($arr_my_ph_num);
$check=get_db_msg("select color from web_kh where id='".$khid."'");
$str=explode(",",$check["color"]);
foreach($str as $value){
$num_my=get_order_num_kh_color($khid,$value);
$money1=get_order_je_kh_color($khid,$value);
$money_my=deel_0($money1[0]);
if($num_my>0){
$ph_my2=get_main_key($arr_my_ph_num,$num_my);
$ph_my2++;
}else{
$ph_my2="";
}
$json_data1.="\"".$value."\",";
$json_data2.="\"".$num_my."\",";
$json_data3.="\"".$money_my."\",";
$json_data4.="\"".$ph_my2."\",";
}
}
//该款已订件数,金额
echo $json_data.="\"ydjsa\":\"".$num_my."\",\"ydjea\":\"".$money_my."\",\"ph_my2\":\"".$ph_my2."\",\"ds_ph_my2\":[".substr($json_data4,0,-1)."],\"ds_color\":[".substr($json_data1,0,-1)."],\"ds_num\":[".substr($json_data2,0,-1)."],\"ds_je\":[".substr($json_data3,0,-1)."]}";
exit;
}
if($arr_ph_ms[0]!=""){
$json_data.="\"is_ph_state\":\"ok\",";
//
$arr_op_ph_ms=array();
for($i=0;$i<count($arr_ph_ms);$i++){
$tmp=explode("|",$arr_ph_ms[$i]);
if($i==0){
$default_ph_ms=$tmp[0];
$default_ph_num=$tmp[1];
}
$arr_op_ph_ms[$tmp[0]]=d_translate($tmp[0]);
}
$s_ph_ms=$s_ph_ms?$s_ph_ms:$default_ph_ms;
//
for($i=0;$i<count($arr_ph_ms);$i++){
$tmp=explode("|",$arr_ph_ms[$i]);
if($s_ph_ms==$tmp[0])
$ph_num=$tmp[1];
}
$s_ph_num=$s_ph_ms?$ph_num:$default_ph_num;
$s_ph_num=$s_ph_num>0?$s_ph_num:0;
if($s_ph_ms=="ph_ds"){
$con_group_by="no,color";
$hj_colspan=6;
}else{
$con_group_by="no";
$hj_colspan=6;
}
$s_order=$s_order?$s_order:"num";
$s_desc=$s_desc?$s_desc:"d1";
//我的排行表过滤区域条件
if($s_qy && $s_qy!="-all-")
$str1=" and qy='".$s_qy."'";
else
$str1="";
$con112=str_replace($str1,"",$con);
//区域
$op="";
$q="select id,title from ".$table_pre."client where face='9' order by title";
$r=$db->query($q);
$i=0;
$arr_op=array();
$arr_op["-all-"]="区域过滤";
while($m=$db->fetch_array($r)){
$arr_op[$m["id"]]=$m["title"];
$i++;
}
$i1=0;
//排行模式
if(count($arr_ph_ms)>1){
$search_select_no[$i1]="s_ph_ms";
$search_select_op[$i1]=$arr_op_ph_ms;
$i1++;
}
//区域选项
if($i>0){
$search_select_no[$i1]="s_qy";
$search_select_op[$i1]=$arr_op;
$i1++;
}
//饰品款过滤
if($is_spk=="y"){
$search_select_no[$i1]="s_is_sp";
$search_select_op[$i1]=array(""=>"".d_translate("spk"),"n"=>"不含".d_translate("spk"),"y"=>"".d_translate("spk"));
$i1++;
}
//选项前面
$select_qm="";
$arr_sz=array();
for($i=0;$i<count($search_select_no);$i++){
$tmp="";
foreach($search_select_op[$i] as $key=>$value){
$tmp.="{\"no\":\"".$key."\",\"title\":\"".$value."\"},";
$arr_sz[$i]=$value;
}
$tmp=deel_end($tmp);
$var=$search_select_no[$i];
$select_qm.="{\"no\":\"".$search_select_no[$i]."\",\"title\":\"".$search_select_op[$i][0]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
$select_qm=deel_end($select_qm);
$json_data.="\"select_qm\":[".$select_qm."],";
//取得定制选项
$select_dz="";
for($i=0;$i<count($arr_select_no);$i++){
//取得选项
$tmp="";
$r1=$db->query("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);
$var="s_".$arr_select_no[$i];
$select_dz.="{\"no\":\"".$arr_select_no[$i]."\",\"title\":\"".$arr_select_title[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
$select_dz=deel_end($select_dz);
$json_data.="\"select_dz\":[".$select_dz."],";
$i1=0;
$search_select_no=array();
$search_select_op=array();
if($s_ph_ms=="ph_ds"){
$con_kc="";
foreach($sys_color_zd as $k1 => $v1){
$v="s_color_".$k1;
if($$v)
$con_kc.=" and kc.".$k1."='".$$v."'";
$r1=$db->query("select ".$k1." from ".$table_pre."kh_color where ".$k1."<>'' group by ".$k1." order by ".$k1);
$search_select_no[$i1]=$v;
$search_select_op[$i1][""]=$v1."过滤";
while($m1=$db->fetch_array($r1)){
$search_select_op[$i1][$m1[$k1]]=$m1[$k1];
}
$i1++;
}
}
//
$search_select_no[$i1]="s_desc";
$search_select_op[$i1]=array("d1"=>"".$s_ph_num."","d2"=>"".$s_ph_num."");
$i1++;
$search_select_no[$i1]="s_order";
$search_select_op[$i1]=array("num"=>"数量排序","je"=>"金额排序");
$i1++;
//选项后
$select_hm="";
$arr_sz=array();
for($i=0;$i<count($search_select_no);$i++){
$tmp="";
foreach($search_select_op[$i] as $key=>$value){
$tmp.="{\"no\":\"".$key."\",\"title\":\"".$value."\"},";
$arr_sz[$i]=$value;
}
$tmp=deel_end($tmp);
$var=$search_select_no[$i];
$select_hm.="{\"no\":\"".$search_select_no[$i]."\",\"title\":\"".$search_select_op[$i][0]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
$select_hm=deel_end($select_hm);
$json_data.="\"select_hm\":[".$select_hm."],";
//
//表头
$json_data.="\"table_top\":[\"|全国排名\",\"this|款号\",";
$content_thead[0]="\"w:40|序号\",\"w:60|全国<br>排名\",\"w:40|".d_translate("xh")."\",\"款号\",";
//如果启用多品牌
if($s_brand && $is_brand=="y")
$con_brand1=" where brand='".$s_brand."'";
else
$con_brand1="";
//
if($s_ph_ms=="ph_ds"){
$content_thead[0].="\"颜色\",";
$json_data.="\"颜色\",";
$group_by_ph1="no,color";
}else{
$content_thead[0].="\"颜色/色总排名\",";
$json_data.="\"颜色/色总排名\",";
//取得色总排名
$arr_ph_color=array();
$q1="select sum(num) 'num',sum(je) 'je' from ".$table_pre."ph ".$con_brand1." group by no,color order by ".$s_order." desc";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$arr_ph_color[]=$m1[$s_order];
}
$group_by_ph1="no";
}
//取得全国排名数组
$arr_ph=array();
$ctt=1;
$q1="select sum(num) 'num',sum(je) 'je',".$group_by_ph1." from ".$table_pre."ph ".$con_brand1." group by ".$group_by_ph1." order by ".$s_order." desc";
$r1=$db->query($q1);
$arr_qgdl=array();
while($m1=$db->fetch_array($r1)){
//$arr_ph[]=$m1[$s_order];
/*if($s_ph_ms=="ph_ds"){
$arr_qgdl[$m1["no"]."_".$m1["color"]]=$ctt;
}else{
$arr_qgdl[$m1["no"]]=$ctt;
}
$ctt++;*/
$arr_ph[]=$m1[$s_order];
if($s_ph_ms=="ph_ds"){
$arr_qgdl[$m1["no"]."_".$m1["color"]]=$m1["num"];
}else{
$arr_qgdl[$m1["no"]]=$m1["num"];
}
}
$content_thead[0].="\"w:50|".d_translate("dpj")."\",\"w:60|我的排名\",\"w:60|我的数量\",\"w:60|".d_translate("dpje")."\"";
$json_data.="\"".d_translate("dpj")."\",\"我的排名\",\"我的数量\",\"".d_translate("dpje")."\"],";
//
$content_tbody=array();
$ds_tbody=array();
$json_data.="\"table_mid\":[";
$order_ph=($s_desc=="d1")?" desc":"";
//取得款号总数
$tmp=get_db_msg("select count(distinct ".$con_group_by.") 'num' from ".$table_pre."ph where no<>'' ".$con);
$total_kh=$tmp["num"];
//取得我的排行
$ctt2=1;
$arr_my_ph_num=array();
$q1="select sum(num) 'num',sum(je) 'je',".$con_group_by." from ".$table_pre."order where ka<>'y' and uid='".$uid."' and _key='".$_key."' ".$con112." group by ".$con_group_by." order by ".$s_order." desc";
//echo $q1."<br>";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
//$arr_my_ph_num[]=$m1["num"];
if($s_ph_ms=="ph_ds"){
$arr_my_ph_num[$m1["no"]."_".$m1["color"]]=$ctt2;
}else{
$arr_my_ph_num[$m1["no"]]=$ctt2;
}
$ctt2++;
}
//$arr_my_ph_num=array_unique($arr_my_ph_num);
//
//$q1="select iid,no,color,sum(num) 'num',sum(je) 'je' from (select p.iid,p.no,p.color,num,je from ".$table_pre."ph p left join ".$table_pre."kh_color kc on kc.iid=p.iid and kc.color=p.color where num>0 ".$con.$con_kc." group by no,color) b group by ".$con_group_by." order by ".$s_order.$order_ph." limit 0,".$s_ph_num;
$q1="select iid,no,color,sum(num) 'num',sum(je) 'je' from ".$table_pre."ph where num>0 ".$con." group by ".$con_group_by." order by ".$s_order.$order_ph." limit 0,".$s_ph_num;
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$page_total_num++;
}
if($page_total_num>=$s_ph_num) $page_total_num=$s_ph_num;
$pages=ceil($page_total_num/$page_num);
if(!$page) $page=1;
$limit_con=($page-1)*$page_num;
//$q="select iid,no,color,sum(num) 'num',sum(je) 'je' from (select p.iid,p.no,p.color,num,je from ".$table_pre."ph p left join ".$table_pre."kh_color kc on kc.iid=p.iid and kc.color=p.color where num>0 ".$con.$con_kc." group by no,color) b group by ".$con_group_by." order by ".$s_order.$order_ph." limit ".$limit_con.",".$page_num."";
$q="select iid,no,color,sum(num) 'num',sum(je) 'je' from ".$table_pre."ph where num>0 ".$con." group by ".$con_group_by." order by ".$s_order.$order_ph." limit ".$limit_con.",".$page_num."";
//echo $q."<br>";
$total_num=$total_money=$count=0;
$count_my=$count_total=0;
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$m1=get_db_msg("select id,no,xh,main_pic,color,size_group from ".$table_pre."kh where id='".$m["iid"]."'");
if($s_ph_ms=="ph_ds"){
$dl=$arr_qgdl[$m1["no"]."_".$m["color"]];
}else{
$dl=$arr_qgdl[$m1["no"]];
}
//$pm=$dl;
$pm=get_main_key($arr_ph,$dl)+1;
if($s_desc=="d2" || ($pm<=$s_ph_num && $s_desc=="d1")){
$sty2=($count%2)?"td2":"td1";
$list=$page_num*($page-1)+$count+1;
$price1=get_price_dp($uid,$m1["id"]);
if($s_ph_ms=="ph_ds"){
$num_my=get_order_num_kh_color($m["iid"],$m["color"]);
$money1=get_order_je_kh_color($m["iid"],$m["color"]);
$money_my=$money1[0];
}else{
$num_my=get_order_num_kh($m1["id"]);
$money1=get_order_je_kh($m["iid"]);
$money_my=$money1[0];
}
$total_num+=$num_my;
$total_money+=$money_my;
$ph_my="";
if($num_my>0){
if($s_ph_ms=="ph_ds"){
$ph_my=$arr_my_ph_num[$m1["no"]."_".$m["color"]];
}else{
$ph_my=$arr_my_ph_num[$m1["no"]];
}
//$ph_my++;
$count_my++;
}
if($list<11){
if($s_ph_ms=="ph_ds"){
$pic=get_kh_color_picture($m1["no"],$m["color"],$flag_pad_offline);
$pic2=get_kh_color_picture_big($m1["no"],$m["color"]);
}else{
$pic=get_kh_picture($m1["no"],$m1["main_pic"],$m1["color"],$flag_pad_offline);
$pic="'".$pic."' ".str_replace("\"","'",out_good_pic_set($pic,80,80))." border=0";
$pic2=get_kh_picture_big($m1["no"],$m1["main_pic"],$m1["color"],$flag_pad_offline);
}
}else{
if($s_ph_ms=="ph_ds"){
$pic=get_kh_color_picture($m1["no"],$m["color"],$flag_pad_offline);
$pic2=get_kh_color_picture_big($m1["no"],$m["color"]);
}else{
$pic=get_kh_picture($m1["no"],$m1["main_pic"],$m1["color"],$flag_pad_offline);
$pic="'".$pic."' ".str_replace("\"","'",out_good_pic_set($pic,80,80))." border=0";
$pic2=get_kh_picture_big($m1["no"],$m1["main_pic"],$m1["color"],$flag_pad_offline);
}
}
if($s_ph_ms=="ph_ds"){
//排行到色
$tmp_arr=explode(",",$m1["color"]);
$color_flag="";
if(count($tmp_arr)>1){
for($i1=0;$i1<count($tmp_arr);$i1++){
$color_flag.=$tmp_arr[$i1]."-".get_cate_title_no("color",$tmp_arr[$i1]).",";
}
if($color_flag)
$color_flag=" (".substr($color_flag,0,-1).")";
}
$content_tbody[$count_total]="\"".$m1["id"]."\",\"pma|".$pm."\",\"this|".get_kh_xh($m1,$m["color"])."|".$m1["id"]."|".$pic."|".$m1["no"].$color_flag."|".$pic2."\",";
$content_tbody[$count_total].="\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\",";
$ds_tbody[$count_total]="\"".$m["color"]."\"";
}else{
$content_tbody[$count_total]="\"".$m1["id"]."\",\"pma|".$pm."\",\"this|".get_kh_xh($m1,$m["color"])."|".$m1["id"]."|".$pic."|".$m1["no"]."|".$pic2."\",";
//取得颜色
$q2="select color,sum(num) 'num',sum(je) 'je' from ".$table_pre."ph where iid='".$m["iid"]."' group by color order by ".$s_order." desc";
$r2=$db->query($q2);
$str_color="";
while($m2=$db->fetch_array($r2)){
$str_color.=$m2["color"]."-".get_cate_title_no("color",$m2["color"])." / ".(get_main_key($arr_ph_color,$m2[$s_order])+1)."|";
}
if($str_color)
$str_color=substr($str_color,0,-1);
$content_tbody[$count_total].="\"color|".$str_color."\",";
}
if($m1["size_group"]==$child_sizegroup_id){
$qa="select * from ".$table_pre."size_bx where no='".$m1["no"]."' order by id";
$ra=$db->query($qa);
$str_tzbx="";
while($ma=$db->fetch_array($ra)){
$str_tzbx.=$ma["bx"].":".$ma["price"]."<br>";
}
$content_tbody[$count_total].="\"".$str_tzbx."\",\"my_pm|".$ph_my."\",\"bianhua|".$num_my."\",\"je|".deel_num($money_my)."\"";
}else{
$content_tbody[$count_total].="\"".deel_num($price1)."\",\"my_pm|".$ph_my."\",\"bianhua|".$num_my."\",\"je|".deel_num($money_my)."\"";
}
$count++;
$count_total++;
}
}
//var_dump($content_tbody);
foreach($content_tbody as $value){
$json_data1.="[".$value."],";
}
foreach($ds_tbody as $value){
$json_data2.="[".$value."],";
$ds_num++;
}
$json_data.=substr($json_data1,0,-1)."],";
if($ds_num)
$json_data.="\"ds\":\"1\",\"ds_color\":[".substr($json_data2,0,-1)."],";
$json_data.="\"pages\":\"".$pages."\",";
$json_data.="\"table_hj\":[";
$content_tbody[$count_total]="\"cs:".$hj_colspan." a:r|合计\",\" a:r|".deel_bfb1($count_my,$count_total,1)."\",\"a:r|".$total_num."\",\"a:r|".$total_money."\"";
$json_data.="\"".$hj_colspan."\",\"".deel_bfb1($count_my,$count_total,1)."\",\"".$total_num."\",\"".$total_money."\"],";
$js_body="$(function () { $(\".fix1\").fixedtableheader(); });";
}else{
$json_data.="\"is_ph_state\":\"nook\",";
$json_data.="\"pages\":\"0\",";
}
break;
}
$json_data=substr($json_data,0,-1)."}";
echo $json_data;
?>