'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"];
}
//文胸
if($bx_sizegroup_title){
$tmp=get_db_msg("select id from ".$table_pre."keyword where cate='size' and title='".$bx_sizegroup_title."' limit 0,1");
$bx_sizegroup_id=$tmp["id"];
}else{
$bx_sizegroup_id=0;
}
//童装
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;
}
$con_spk=($is_spk=="y")?" and is_sp<>'y'":"";
$flag_spk=($is_spk=="y")?"1":"";
//------------------------------------包含定制模块,店铺界面,顶部已订数和完成率的显示
//include_once $path_dz."/dp/wcl.php";
//
//--------------交单按钮
$jd_password=get_set("jd_password");
if($is_brand<>"y"){
$tmp=$msg_login;
$is_jd=$msg_login["is_jd"];
$is_checked=$msg_login["is_checked"];
}else{
$tmp=get_db_msg("select is_jd from ".$table_pre."client_brand where cid='".$uid."'".$con_brand." order by is_jd limit 0,1");
$is_jd=$tmp["is_jd"];
$tmp=get_db_msg("select is_checked from ".$table_pre."client_brand where cid='".$uid."'".$con_brand." order by is_checked limit 0,1");
$is_checked=$tmp["is_checked"];
}
if($show_jd=="y"){
if($is_jd=="y")
$jd_button="已交单|";
if($is_checked=="y")
$jd_button="已确认|";
if($is_brand=="y"){
$jd_button="交单|go_url('".$_SERVER[PHP_SELF]."?_m=".$_m."&_a=o&s_tab=wcl')";
}else{
if($is_jd!="y" && $is_checked!="y")
$jd_button="交单|do_jd('".$jd_password."','".$_SERVER[PHP_SELF]."?_m=".$_m."&_a=jd".$link_var_brand."')";
}
}else{
$jd_button="|";
}
//计算订货规则按钮
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."gz where dj='' or dj='".$msg_login["dj"]."'");
if($tmp["num"]>0)
$menu_dhgz="订货规则";
else
$menu_dhgz="";
switch($_a){
case "single":
$w2=$tmpl_m3_pic_width;
$h2=$tmpl_m3_pic_height;
$cl_lie=$tmpl_m3_lie;
$s_con=$s_con?$s_con:$s_con_default;
$rurl=$rurl?$rurl:get_this_url();
$json_data.="\"w2\":\"".$w2."\",";
$json_data.="\"h2\":\"".$h2."\",";
$json_data.="\"cl_lie\":\"".$cl_lie."\",";
//$json_data.="\"rurl\":\"".$rurl."\",";
if($zsh){
$s_zsh=$zsh;
}
$msg_err="";
$kl=strlen($s_title);
if($kl<=3 && $s_title && is_numeric($s_title)){
$sql_con="where xh='".$s_title."'";
}
if($kl>=3){
if(is_numeric($s_title)){
$sql_con="where xh='".$s_title."' or no like '%".$s_title."%'";
}else{
$sql_con="where no like '%".$s_title."%'";
}
}
if($s_title){
$msg=get_db_msg("select * from ".$table_pre."kh ".$sql_con);
$m1=get_db_msg("select count(*) 'num' from ".$table_pre."kh ".$sql_con);
$json_data.="\"khid\":\"".$msg["id"]."\",";
$json_data.="\"s_title\":\"".$s_title."\",";
$id=$msg["id"];
$str_title="";
if($m1["num"]>1){
$q2="select * from ".$table_pre."kh ".$sql_con;
$r2=$db->query($q2);
while($m2=$db->fetch_array($r2)){
$str_title.="{\"khid\":\"".$m2["id"]."\",\"title\":\"".$m2["xh"]."#".$m2["no"]."\"},";
}
if($msg_err){
$str_title=deel_end($str_title);
$msg_err="存在以下符合条件的多个款:".$msg_err;
}
}
//
if(!$id){
$msg_err="记录不存在";
}
}
if($msg_err){
if($str_title){
$json_data.="\"code\":101,";
$json_data.="\"msg\":[".$str_title."],";
}else{
$json_data.="\"code\":102,";
$json_data.="\"msg\":\"".$msg_err."\",";
}
}else{
$json_data.="\"code\":100,";
if($s_zsh){
$sql_con.=" where zsh='".$s_zsh."' and ";
$s_no="";
}
$sql_con=substr($sql_con,0,-4);
//取得总设计款数
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ka<>'y'");
$total_ks=$tmp["num"];
//取得已订总款数
if($msg_login["face"]=="4"){
$tmp=get_db_msg("select count(distinct(iid)) 'num' from ".$table_pre."order where uid='".$uid."' and _key='".$_key."'");
}
if($msg_login["face"]=="2"){
$tmp=get_db_msg("select count(distinct(iid)) 'num' from ".$table_pre."order where ka<>'y' and _key='".$_key."' ".get_qj_ucon_all_dpid($msg_login["charge_uid"],""));
}
$total_yd_ks=$tmp["num"];
//定制条件
$query="select * from ".$table_pre."kh_cl where zsh='".$s_zsh."' group by kh,color order by ord";
//echo $query."
";
$res=$db->query($query);
$style_title_color=get_set("style_title_color");
$ka_color=get_set("ka_color");
$pic_background=get_set("pic_background");
$pic_background=$pic_background?$pic_background:"#ffffff";
$content_set="[\"".$pic_background."\"]";
$json_data.="\"content_set\":\"".$pic_background."\",";
$json_data.="\"style_title_color\":\"".$style_title_color."\",";
$json_data.="\"ka_color\":\"".$ka_color."\",";
$num_arr="";
$strarr="";
$count=0;
$rnum=0;
$zks=$ydjs=$ydks=0;
$content_list="";
$title=$cljs="";
$clp="";
while($msg1=$db->fetch_array($res)){
$clp=$msg1["pic"];
$title=$msg1["title"];
$cljs=htmlspecialchars($msg1["remark"]);
$msg=get_db_msg("select * from ".$table_pre."kh where no='".$msg1["kh"]."'");
if($msg["id"]>0){
if($msg["ka"]=="y"){
$c=get_set("ka_color");
}else{
$c=get_set_value_dote($style_title_color,$msg["kh_dj"]);
}
//图片获取规则
$pic=get_kh_color_picture($msg["no"],$msg1["color"],$flag_pad_offline);
if($msg_login["face"]=="4"){
$n1=deel_num(get_order_num_kh_color($msg["id"],$msg1["color"]));
}
if($msg_login["face"]=="2"){
$tmp=get_db_msg("select sum(num) 'num' from ".$table_pre."order where ka<>'y' and _key='".$_key."' and iid='".$msg["id"]."' and color='".$msg1["color"]."' ".get_qj_ucon_all_dpid($msg_login["charge_uid"],""));
$n1=deel_num($tmp["num"]);
}
//$content_list.="".$msg["id"].",".$msg1["ord"].",\"".get_kh_xh($msg,$msg1["color"])."\",\"".$msg["no"]."\",\"".$msg1["color"]."\",\"".get_cate_title_no("color",$msg1["color"])."\",".deel_num(get_price_dp($uid,$msg["id"])).",\"".$pic."\",\"".str_replace("\"","'",out_good_pic_set($pic,$w2,$h2))."\",".$n1.",\"".$c."\",";
$tmppic=out_good_pic_set_arr($pic,$w2,$h2);
$content_list.="{\"id\":\"".$msg["id"]."\",\"kh_dj\":\"".get_cate_title_no("kh_dj",$msg["kh_dj"])."\",\"ord\":\"".$msg1["ord"]."\",\"yph\":\"".get_kh_xh($msg,$msg1["color"])."\",\"kh\":\"".$msg["no"]."\",\"color\":\"".$msg1["color"]."\",\"color_title\":\"".get_cate_title_no("color",$msg1["color"])."\",\"price\":\"".deel_num(get_price_dp($uid,$msg["id"]))."\",\"pic\":\"".$pic."\",\"pic_w\":".$tmppic[0].",\"pic_h\":".$tmppic[1].",\"ydj\":".$n1.",\"c\":\"".$c."\"},";
$rnum++;
$count++;
//计算已订款数
if($msg_login["face"]=="4"){
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."order where uid='".$uid."' and iid='".$msg["id"]."' and color='".$msg1["color"]."' and ka<>'y' and _key='".$_key."'");
if($tmp["num"]>0)
$ydks++;
}
if($msg_login["face"]=="2"){
if($n1>0)
$ydks++;
}
//计算总款数
$zks++;
//计算已订件数
if($msg_login["face"]=="4"){
$tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where uid='".$uid."' and iid='".$msg["id"]."' and color='".$msg1["color"]."' and ka<>'y' and _key='".$_key."'");
$ydjs+=$tmp["num"];
}
if($msg_login["face"]=="2"){
$ydjs+=$n1;
}
}
}
$content_list=substr($content_list,0,-1);
$json_data.="\"cls\":[".$content_list."],";
$json_data.="\"title\":\"".$title."\",";
$json_data.="\"cljs\":\"".$cljs."\",";
$json_data.="\"zk\":\"".$total_ks."\",";
$json_data.="\"zydk\":\"".$total_yd_ks."\",";
$json_data.="\"bzk\":\"".$zks."\",";
$json_data.="\"bzydk\":\"".$ydks."\",";
$json_data.="\"bzydj\":\"".$ydjs."\",";
$json_data.="\"total\":\"".add_0($count)."\",";
//上一组、下一组
$pre_xh=get_db_msg("select zsh from ".$table_pre."kh_cl where zsh<'".$s_zsh."' order by zsh desc limit 0,1");
$next_xh=get_db_msg("select zsh from ".$table_pre."kh_cl where zsh>'".$s_zsh."' order by zsh limit 0,1");
$str_sxk="[\"".$pre_xh["zsh"]."\",\"".$next_xh["zsh"]."\"]";
$json_data.="\"prev\":\"".$pre_xh["zsh"]."\",";
$json_data.="\"next\":\"".$next_xh["zsh"]."\",";
$clpic=get_kh_cl_big($clp,$flag_pad_offline);
$tmppic=out_good_pic_set_arr($clpic,$tmpl_m3_cl_pic_width,$tmpl_m3_cl_pic_height);
$json_data.="\"pic_big\":\"".$clpic."\",";
$json_data.="\"pic_big_w\":\"".$tmppic[0]."\",";
$json_data.="\"pic_big_h\":\"".$tmppic[1]."\",";
}
break;
default:
//----------------------------------------------陈列模式
if($sys_zycl=="y"){
$s_type=$s_type?$s_type:"1";
}
$num_cl_zd=0;
if(is_array($sys_cl_zd)){
$num=count($sys_cl_zd);
$num_cl_zd=($num<5)?$num:5;
}
$json_data.="\"sys_zycl\":\"".$sys_zycl."\",";
//require THIS_FILE_ROOT."/include/page_js.class.php";
$w2=$tmpl_m3_cl_pic_width;
$h2=$tmpl_m3_cl_pic_height;
$page_size=$tmpl_m1_page_size;
$page_size=$tmpl_m1_page_size;
$page=$page>0?$page:1;
$limit=$limit>0?$limit:6;
$start=($page-1)*$limit;
$end=$limit;
//
$sql_con=" where zsh>0 and ";
if($s_type){
$sql_con.=get_sql_client_type($s_type);
}
/*if($s_no){
$sql_con.="kh like '%".$s_no."%' and ";
$s_zsh="";
}*/
$kl=strlen($s_keyword);
if($kl<=3 && $s_keyword && is_numeric($s_keyword)){
if($xh_ms=="2"){
$tmp=get_db_msg("select kh as no from web_kh_xh where xh='".$s_keyword."'");
}else{
$tmp=get_db_msg("select no from web_kh where xh='".$s_keyword."'");
}
$sql_con.=" kh='".$tmp["no"]."' and";
for($i=0;$i<$num_dp_zd;$i++){
$v1="s_zd".($i+1);
$$v="";
}
$s_zsh="";
$s_title="";
}
if($kl>=3){
if(is_numeric($s_keyword)){
if($xh_ms=="2"){
$tmp=get_db_msg("select kh as no from web_kh_xh where xh='".$s_keyword."'");
}else{
$tmp=get_db_msg("select no from web_kh where xh='".$s_keyword."'");
}
$sql_con.=" (kh='".$tmp["no"]."' or kh like '%".$s_keyword."%') and";
}else{
$sql_con.=" (kh like '%".$s_keyword."%') and";
}
for($i=0;$i<$num_dp_zd;$i++){
$v1="s_zd".($i+1);
$$v="";
}
$s_zsh="";
$s_title="";
}
if($s_title){
$sql_con.="title like '%".$s_title."%' and ";
$s_keyword="";
$s_zsh="";
}
for($i=0;$i<$num_cl_zd;$i++){
$v1="s_zd".($i+1);
if($$v1)
$sql_con.="zd".($i+1)."='".$$v1."' and ";
}
if($sql_con)
$sql_con=substr($sql_con,0,-4);
//$sql_order=str_replace("!"," desc",$order);
$json_data.="\"s_keyword\":\"".$s_keyword."\",";
$json_data.="\"s_zsh\":\"".$s_zsh."\",";
$json_data.="\"s_title\":\"".$s_title."\",";
$query="select count(distinct zsh) 'total' from ".$table_pre."kh_cl ".$sql_con;
$res=$db->query($query);
$msg=$db->fetch_array($res);
$total=$msg["total"];
//定制条件
$query="select * from ".$table_pre."kh_cl ".$sql_con." group by zsh order by zsh limit ".$start.",".$end;
//echo $query."
";
$res=$db->query($query);
$count=0;
$rnum=0;
$style_title_color=get_set("style_title_color");
$ka_color=get_set("ka_color");
$pic_background=get_set("pic_background");
$pic_background=$pic_background?$pic_background:"#ffffff";
$content_set="[\"".$pic_background."\"]";
$json_data.="\"style_title_color\":\"".$style_title_color."\",";
$json_data.="\"ka_color\":\"".$ka_color."\",";
$json_data.="\"content_set\":\"".$pic_background."\",";
$json_data.="\"count\":".$total.",\"content_list\":[";
$data_str="";
$content_list="[";
for($count=0;$count<$end;$count++){
$msg=$db->fetch_array($res);
if($msg["id"]>0){
//图片获取规则
$pic=get_kh_cl_mini($msg["pic"],$flag_pad_offline);
if(($msg_login["path"]."-".$msg_login["id"])==$msg["upath"])
$is_my_cl="y";
else
$is_my_cl="n";
$content_list.=$msg["zsh"].",\"".$pic."\",\"".str_replace("\"","'",out_good_pic_set($pic,$w2,$h2))."\",\"".$msg["title"]."\",\"".$is_my_cl."\",";
$ck=out_good_pic_set_arr($pic,$w2,$h2);
$data_str.="{\"zsh\":".$msg["zsh"].",\"title\":\"".$msg["title"]."\",\"is_my_cl\":\"".$is_my_cl."\",\"pic\":\"".$pic."\",\"pic_w\":".$ck[0].",\"pic_h\":".$ck[1]."},";
//
$rnum++;
}
}
$json_data.=substr($data_str,0,-1)."],";
$content_list.="]";
//自定义筛选条件
$str_arr_zy="";
$select_dz="";
if($sys_zycl=="y"){
$tmp1=explode(",",$sys_zycl_client_type);
foreach($tmp1 as $k1 => $v1){
$tmp2=explode("|",$v1);
$str_arr_zy.="{\"no\":\"".$tmp2[0]."\",\"title\":\"".$tmp2[1]."\"},";
/*foreach($tmp2 as $k2 => $v2){
$str_arr_zy.="{\"no\":\"".$k2."\",\"title\":\"".$v2."\"},";
}*/
}
$str_arr_zy=deel_end($str_arr_zy);
$select_dz.="{\"no\":\"s_type\",\"title\":\"陈列类型\",\"value\":\"".$s_type."\",\"op\":[".$str_arr_zy."]},";
}
$str_arr_select="";
for($i=0;$i<$num_cl_zd;$i++){
$v1="s_zd".($i+1);
$str_arr_select.="\"".$v1."\",\"".$sys_cl_zd[$i]."\",\"".$$v1."\",";
$r=$db->query("select zd".($i+1)." from ".$table_pre."kh_cl group by zd".($i+1)." order by zd".($i+1));
$op="[";
$tmp="";
while($m=$db->fetch_array($r)){
$op.="\"".$m["zd".($i+1)]."|".$m["zd".($i+1)]."\",";
$tmp.="{\"no\":\"".$m["zd".($i+1)]."\",\"title\":\"".$m["zd".($i+1)]."\"},";
}
$tmp=deel_end($tmp);
$select_dz.="{\"no\":\"".$v1."\",\"title\":\"".$sys_cl_zd[$i]."\",\"value\":\"".$$v1."\",\"op\":[".$tmp."]},";
$op.="],";
$str_arr_select.=$op;
}
$select_dz=deel_end($select_dz);
$json_data.="\"select_dz\":[".$select_dz."],";
$total_page=ceil($total/$limit);
$json_data.="\"total_page\":".$total_page.",";
$json_data.="\"page\":".$page.",";
break;
}
}
$json_data=substr($json_data,0,-1)."}";
echo $json_data;
?>