'zgdl' and no<>'dhbs' and no<>'qdl' and no<>'glk' and no<>'zxs' and flag_ka='y' order by ord";
$r=$db->query($q);
$i=0;
while($m=$db->fetch_array($r)){
$check=get_db_msg("select count(*) 'num' from ".$table_pre."gz where cate='".$m["no"]."' and (dj='' or dj='".$msg_login["dj"]."')");
if($check["num"]>0){
$arr_gz[$m["no"]]=$m["title"];
$arr_gz1[$i]=$m["no"];
$i++;
}
}
$my_gz_type=$my_gz_type?$my_gz_type:$arr_gz1[0];
$json_data.="\"gz\":\"".$my_gz_type."\",";
//tab
$content_tab="";
$strgz="";
$i=0;
foreach($arr_gz as $k => $v){
$strgz.="{\"xh\":\"".$i."\",\"k\":\"".$k."\",\"v\":\"".$v."\"},";
$i++;
$s=($my_gz_type==$k)?"y":"";
$content_tab.="?_m=".$_m."&_a=".$_a."&s_tab=".$s_tab."&my_gz_type=".$k."|".$v."|".$s.",";
}
$json_data.="\"arr_gz\":[".deel_end($strgz)."],";
if($content_tab)
$content_tab=substr($content_tab,0,-1);
//取得客户等级
$client_dj=trim($msg_login["dj"]);
$con_dj=$client_dj?" and (dj='".$client_dj."' or dj='')":" and dj=''";
$strhead=$strbody="";
if($my_gz_type=="bdk"){
//必订款
$strhead.="{\"v\":\"款号\"},{\"v\":\"必订数量\"},{\"v\":\"实际数量\"},";
//$content="
";
//$content.="| 款号 | ";
//$content.="必订数量 | 实际数量 | ";
//$content.="
";
$q1="select * from ".$table_pre."gz where cate='".$my_gz_type."'".$con_dj." order by kh";
$r1=$db->query($q1);
$count=0;
while($m1=$db->fetch_array($r1)){
$sty1=($count%2)?"#f5f5f5":"white";
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$m1["kh"]."'");
//取得实际数量
$tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where no='".$m1["kh"]."' and uid='".$uid."' and _key='".$_key."'");
if($tmp["num"]<$m1["num"])
$bg_hilight=" style='color:#ffffff;background-color:#ff0000;'";
else
$bg_hilight="";
$tmpb="";
$strbody.="{";
$strbody.="\"sty\":\"".$sty1."\",";
$strbody.="\"khid\":\"".$m_kh["id"]."\",";
$tmpb.="{\"s\":\"\",\"v\":\"".$m_kh["no"]."\"},{\"s\":\"\",\"v\":\"".$m1["num"]."\"},{\"s\":\"".$bg_hilight."\",\"v\":\"".add_0($tmp["num"])."\"}";
$strbody.="\"body\":[".$tmpb."]";
$strbody.="},";
//$content.="| ".$m_kh["no"]." | ".$m1["num"]." | ".add_0($tmp["num"])." |
";
$count++;
}
}else if($my_gz_type=="bdks"){
//必订款色
$strhead.="{\"v\":\"款号\"},{\"v\":\"颜色\"},{\"v\":\"必订数量\"},{\"v\":\"实际数量\"},";
//$content="";
//$content.="| 款号 | 颜色 | ";
//$content.="必订数量 | 实际数量 | ";
//$content.="
";
$q1="select * from ".$table_pre."gz where cate='".$my_gz_type."'".$con_dj." order by kh,color";
$r1=$db->query($q1);
$count=0;
while($m1=$db->fetch_array($r1)){
$sty1=($count%2)?"#f5f5f5":"white";
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$m1["kh"]."'");
//取得实际数量
$tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where no='".$m1["kh"]."' and color='".$m1["color"]."' and uid='".$uid."' and _key='".$_key."'");
if($tmp["num"]<$m1["num"])
$bg_hilight=" style='color:#ffffff;background-color:#ff0000;'";
else
$bg_hilight="";
$tmpb="";
$strbody.="{";
$strbody.="\"sty\":\"".$sty1."\",";
$strbody.="\"khid\":\"".$m_kh["id"]."\",";
$tmpb.="{\"s\":\"\",\"v\":\"".$m_kh["no"]."\"},{\"s\":\"\",\"v\":\"".$m1["color"]."-".get_cate_title_no("color",$m1["color"])."\"},{\"s\":\"\",\"v\":\"".$m1["num"]."\"},{\"s\":\"".$bg_hilight."\",\"v\":\"".add_0($tmp["num"])."\"}";
$strbody.="\"body\":[".$tmpb."]";
$strbody.="},";
//$content.="| ".$m_kh["no"]." | ".$m1["color"]."-".get_cate_title_no("color",$m1["color"])." | ".$m1["num"]." | ".add_0($tmp["num"])." |
";
$count++;
}
}else if($my_gz_type=="bdgg"){
//必订规格
$strhead.="{\"v\":\"款号\"},{\"v\":\"颜色\"},{\"v\":\"".d_translate("gg")."\"},{\"v\":\"必订数量\"},{\"v\":\"实际数量\"},";
//$content="";
//$content.="| 款号 | 颜色 | ".d_translate("gg")." | 必订数量 | 实际数量 | ";
//$content.="
";
$q1="select * from ".$table_pre."gz where cate='".$my_gz_type."'".$con_dj." order by kh,color,bc";
$r1=$db->query($q1);
$count=0;
while($m1=$db->fetch_array($r1)){
$sty1=($count%2)?"#f5f5f5":"white";
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$m1["kh"]."'");
//取得实际数量
$tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where no='".$m1["kh"]."' and color='".$m1["color"]."' and bx='".$m1["bc"]."' and uid='".$uid."' and _key='".$_key."'");
if($tmp["num"]<$m1["num"])
$bg_hilight=" style='color:#ffffff;background-color:#ff0000;'";
else
$bg_hilight="";
$tmpb="";
$strbody.="{";
$strbody.="\"sty\":\"".$sty1."\",";
$strbody.="\"khid\":\"".$m_kh["id"]."\",";
$tmpb.="{\"s\":\"\",\"v\":\"".$m_kh["no"]."\"},{\"s\":\"\",\"v\":\"".$m1["color"]."-".get_cate_title_no("color",$m1["color"])."\"},{\"s\":\"\",\"v\":\"".get_gg_title($m1["bc"])."\"},{\"s\":\"\",\"v\":\"".$m1["num"]."\"},{\"s\":\"".$bg_hilight."\",\"v\":\"".add_0($tmp["num"])."\"}";
$strbody.="\"body\":[".$tmpb."]";
$strbody.="},";
//$content.="| ".$m_kh["no"]." | ".$m1["color"]."-".get_cate_title_no("color",$m1["color"])." | ".get_gg_title($m1["bc"])." | ".$m1["num"]." | ".add_0($tmp["num"])." |
";
$count++;
}
}else if($my_gz_type=="bds"){
//必订色
$strhead.="{\"v\":\"波段\"},{\"v\":\"颜色\"},{\"v\":\"必订数量\"},{\"v\":\"实际数量\"},";
//$content="";
//$content.="| 波段 | 颜色 | ";
//$content.="必订数量 | 实际数量 | ";
//$content.="
";
$q1="select * from ".$table_pre."gz where cate='".$my_gz_type."'".$con_dj." order by kh,color";
$r1=$db->query($q1);
$count=0;
while($m1=$db->fetch_array($r1)){
$sty1=($count%2)?"#f5f5f5":"white";
$bg=($count%2)?"#a8a8a8":"#c8c8c8";
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$m1["kh"]."'");
//取得实际数量
$tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where bc='".$m1["bc"]."' and color='".$m1["color"]."' and uid='".$uid."' and _key='".$_key."'");
if($tmp["num"]<$m1["num"])
$bg_hilight=" style='color:#ffffff;background-color:#ff0000;'";
else
$bg_hilight="";
$tmpb="";
$strbody.="{";
$strbody.="\"sty\":\"".$sty1."\",";
$strbody.="\"bc\":\"".$m1["bc"]."\",";
$strbody.="\"color\":\"".$m1["color"]."\",";
$tmpb.="{\"s\":\"\",\"v\":\"".get_cate_title_no("bc",$m1["bc"])."\"},{\"s\":\"\",\"v\":\"".$m1["color"]."-".get_cate_title_no("color",$m1["color"])."\"},{\"s\":\"\",\"v\":\"".$m1["num"]."\"},{\"s\":\"".$bg_hilight."\",\"v\":\"".add_0($tmp["num"])."\"}";
$strbody.="\"body\":[".$tmpb."]";
$strbody.="},";
//$content.="| ".get_cate_title_no("bc",$m1["bc"])." | ".$m1["color"]."-".get_cate_title_no("color",$m1["color"])." | ".add_0($m1["num"])." | ".add_0($tmp["num"])." |
";
$count++;
}
}else if($my_gz_type=="byxdk"){
//不予下单款
$strhead.="{\"v\":\"款号\"},";
//$content="";
//$content.="| 款号 | ";
//$content.="
";
$q1="select * from ".$table_pre."gz where cate='".$my_gz_type."'".$con_dj." order by kh";
$r1=$db->query($q1);
$count=0;
while($m1=$db->fetch_array($r1)){
$sty1=($count%2)?"#f5f5f5":"white";
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$m1["kh"]."'");
//取得实际数量
$tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where no='".$m1["kh"]."' and uid='".$uid."' and _key='".$_key."'");
$tmpb="";
$strbody.="{";
$strbody.="\"sty\":\"".$sty1."\",";
$strbody.="\"khid\":\"".$m_kh["id"]."\",";
$tmpb.="{\"s\":\"\",\"v\":\"".$m_kh["no"]."\"}";
$strbody.="\"body\":[".$tmpb."]";
$strbody.="},";
//$content.="| ".$m_kh["no"]." |
";
$count++;
}
}else if($my_gz_type=="jebl"){
//金额比例
$strhead.="{\"v\":\"".get_cate_title_no("arr_select","kh_dj")."\"},{\"v\":\"要求占比\"},{\"v\":\"实际占比\"},";
//$content="";
//$content.="| ".get_cate_title_no("arr_select","kh_dj")." | 要求占比 | 实际占比 | ";
//订单总金额
if($is_spk=="y"){
$total_money=$msg_login["order_money1"];
$con_sp=" and is_sp='y'";
}else{
$total_money=$msg_login["order_money"];
$con_sp="";
}
$q1="select * from ".$table_pre."keyword where cate='kh_dj' order by no";
$r1=$db->query($q1);
$count=0;
while($m1=$db->fetch_array($r1)){
$m2=get_db_msg("select * from ".$table_pre."gz where cate='".$my_gz_type."'".$con_dj." and kh='".$m1["no"]."'");
$sty1=($count%2)?"#f5f5f5":"white";
$bg=($count%2)?"#a8a8a8":"#c8c8c8";
//取得实际金额
$q2="select sum((".get_size_sql("sum").")*price) 'je' from ".$table_pre."order where kh_dj='".$m1["no"]."' and uid='".$uid."' and _key='".$_key."'".$con_sp;
$tmp=get_db_msg($q2);
if($m2["id"]>0){
$c1=$m2["color"].deel_num($m2["num"])."%";
if($total_money>0){
$bl=($tmp["je"]/$total_money)*100;
}else{
$bl=0;
}
$gs=$bl.$m2["color"].$m2["num"];
eval("\$r=$gs;");
$bg1=($r==false)?"#ff0000":$bg;
}else{
$c1=" ";
$bg1=$bg;
}
$tmpb="";
$strbody.="{";
$strbody.="\"sty\":\"".$sty1."\",";
$strbody.="\"kh_dj\":\"".$m1["no"]."\",";
$tmpb.="{\"s\":\"\",\"v\":\"".$m1["title"]."\"},{\"s\":\"\",\"v\":\"".$c1."\"},{\"s\":\"".$bg_hilight."\",\"v\":\"".deel_bfb1($tmp["je"],$total_money)."\"}";
$strbody.="\"body\":[".$tmpb."]";
$strbody.="},";
//$content.="
| ".$m1["title"]." | ".$c1." | ".deel_bfb1($tmp["je"],$total_money)." |
";
$count++;
}
$content.="";
}else if($my_gz_type=="bdkshi"){
//必订款式
$strhead.="{\"v\":\"款号\"},{\"v\":\"必订款数\"},{\"v\":\"实际款数\"},";
//$content="";
//$content.="| 款号 | ";
//$content.="必订款数 | 实际款数 | ";
//$content.="
";
$q1="select bc,num from ".$table_pre."gz where cate='".$my_gz_type."'".$con_dj." group by bc";
$r1=$db->query($q1);
$count=0;
while($m1=$db->fetch_array($r1)){
$sty1=($count%2)?"td2":"td1";
//取得款号
$str_kh="";
$q2="select * from ".$table_pre."gz where cate='".$my_gz_type."' and bc='".$m1["bc"]."' order by kh";
$r2=$db->query($q2);
$sj_ydkss=0;
$tmpbb="";
while($m2=$db->fetch_array($r2)){
$m_kh=get_db_msg("select id,no from ".$table_pre."kh where no='".$m2["kh"]."'");
if($m_kh["id"]>0){
//$str_kh.="".$m2["kh"].", ";
$tmpbb.="{\"khid\":\"".$m_kh["id"]."\",\"kh\":\"".$m2["kh"]."\"},";
}
$c=get_db_msg("select id from ".$table_pre."order where no='".$m2["kh"]."' and uid='".$uid."' and _key='".$_key."'");
if($c["id"]>0)
$sj_ydkss++;
}
if($str_kh)
$str_kh=substr($str_kh,0,-1);
//取得实际数量
if($sj_ydkss<$m1["num"])
$bg_hilight=" style='color:#ffffff;background-color:#ff0000;'";
else
$bg_hilight="";
$tmpb="";
$strbody.="{";
$strbody.="\"sty\":\"".$sty1."\",";
$strbody.="\"kh\":[".deel_end($tmpbb)."],";
$tmpb.="{\"s\":\"\",\"v\":\"".$m1["num"]."\"},{\"s\":\"".$bg_hilight."\",\"v\":\"".add_0($sj_ydkss)."\"}";
$strbody.="\"body\":[".$tmpb."]";
$strbody.="},";
//$content.="| ".$str_kh." | ".$m1["num"]." | ".add_0($sj_ydkss)." |
";
$count++;
}
}
$json_data.="\"head\":[".deel_end($strhead)."],";
$json_data.="\"body\":[".deel_end($strbody)."],";
//$content.="
";
$json_data=substr($json_data,0,-1)."}";
echo $json_data;
?>