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/dkold.php
T
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

4714 lines
207 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
//-------------------------------单款订货
/*
店铺和区经角色
*/
header("Content-type: text/html; charset=utf-8");
$json_data="{";
/*if(THIS_IN!="edt_ipad")
exit("错误的访问!");*/
$uid=check_cookie_jxs();
//系统变量
$sys_close=get_set("sys_close");
$sys_close_image=get_set("sys_close_image");
$is_session=get_set("is_session");
$zb_type=get_set("zb_type");
$is_spk=get_set("is_spk");
$zbxf=get_set("zbxf");
$zbxf_type=get_set("zbxf_type");
$sys_ms=get_set("sys_ms");
$is_msg=get_set("is_msg");
$is_ewm=get_set("is_ewm");
$is_window="y";
$zk_type=get_set("zk_type");
$is_hd_log=get_set("is_hd_log");
$xh_ms=get_set("xh_ms");
$order_session=get_set("order_session");
$sys_size_num=get_max_size_num();
//$theme_path=get_theme_path();
$theme_path="";
$pm_ms=get_set("pm_ms");
$str_gg_zd=arr2str($sys_gg_zd,"v");
$tmparrzd=explode(",",$str_gg_zd);
$strzd="";
foreach($tmparrzd as $n => $t){
$strzd.="{\"title\":\"".$t."\"},";
}
$json_data.="\"arr_gg_zd\":[".deel_end($strzd)."],";
$sys_ck_input=get_set("sys_ck_input");
$sys_flag_count=count($arr_sys_order_flag);
$tmpl_m1_page_size=12;
$tmpl_m1_lie=4;
$tmpl_m1_pic_width=188;
$tmpl_m1_pic_height=250;
$tmpl_m1_search_con_num=5;
$tmpl_m2_dp_pic_width=400;
$tmpl_m2_dp_pic_height=400;
$tmpl_order_single_w=300;
$tmpl_order_single_h=400;
$json_data.="\"sys_ver_hy\":\"".$sys_ver_hy."\",";
//$db=_mysql_connect();
$msg_login=get_db_msg("select * from ".$table_pre."client where id='".$uid."'");
if($msg_login["available"]!="y"){
$json_data.="\"error\":\"用户已被禁用\",\"code\":0,\"msg\":\"用户已被禁用\",\"count\":0,\"data\":[],";
}else{
$json_data.="\"face\":\"".$msg_login["face"]."\",";
$json_data.="\"uid\":\"".$msg_login["id"]."\",";
$s_key=$s_key?$s_key:$_key;
$rurl=$rurl?$rurl:get_this_url();
$check_md=get_db_msg("select count(*) 'num' from ".$table_pre."kh_md");
$zb_client_show=get_set("zb_client_show");
if($zb_client_show=="y")
$arr_zb_type=explode(",",$zb_type);
else
$arr_zb_type=array();
$is_brand=is_brand();
$show_jd=get_set("show_jd");
$is_dkds=get_set("is_dkds");
$is_multi_price=get_set("is_multi_price");
$order_close=get_set("order_close");
$search_type=get_set("search_type");
$list_by_color="n"; //是否展示到色
$json_data.="\"show_jd\":\"".$show_jd."\",";
$json_data.="\"is_dkds\":\"".$is_dkds."\",";
$json_data.="\"is_brand\":\"".$is_brand."\",";
$json_data.="\"is_multi_price\":\"".$is_multi_price."\",";
if($is_brand=="y")
$link_var_brand="&s_brand=".$s_brand;
else
$link_var_brand="";
$title_brand=$con_brand="";
if($s_brand){
$arr_s_brand=explode(",",$s_brand);
for($i=0;$i<count($arr_s_brand);$i++){
$con_brand.="brand='".$arr_s_brand[$i]."' or ";
$title_brand.=get_cate_title_no("brand",$arr_s_brand[$i]).",";
}
if($title_brand)
$title_brand=substr($title_brand,0,-1);
if($con_brand)
$con_brand=" and (".substr($con_brand,0,-3).")";
}
//取得选项
$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"];
}
//文胸
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;
}
$json_data.="\"bx_sizegroup_id\":\"".$bx_sizegroup_id."\",";
$json_data.="\"child_sizegroup_id\":\"".$child_sizegroup_id."\",";
$con_spk=($is_spk=="y")?" and is_sp<>'y'":"";
$flag_spk=($is_spk=="y")?"1":"";
//------------------------------------包含定制模块,店铺界面,顶部已订数和完成率的显示
//
//--------------交单按钮
$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="";
if($msg_login["face"]=="4"){
//include_once $path_dz."/dp/wcl.php";
//
switch($_a){
case "get_wcl":
//获取完成率和已订件数,传递参数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 ka<>'y' and _key='".$_key."'");
$k_ydjs=$tmp["num"];
//取得上次订货会数量
$str_sys="";
if($sys_flag_count>1){
$tmp_sys=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where _key<>'".$_key."' and iid='".$khid."' and uid='".$uid."'");
$tmp_kh=get_db_msg("select * from ".$table_pre."kh where id='".$khid."'");
if($tmp_sys["num"]){
$str_sys="\"scjs\":".$tmp_sys["num"].",\"hjjs\":".($tmp_sys["num"]+$n1).",";
}
$str_sys.="\"lssj\":\"y\",\"unit_title\":\"".$tmp_kh["unit_title"]."\",";
}
}else{
$k_ydjs=0;
}
//该款已订件数
$zb_client_show=get_set("zb_client_show");
$json_data.="\"ydjs\":\"".$k_ydjs."\",".$str_sys;
$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."\",";
$str_color_num="";
if($index_by_color=="y"){
$tmp_kh22=get_db_msg("select * from ".$table_pre."kh where id='".$khid."'");
$arr_col=explode(",",$tmp_kh22["color"]);
if(is_array($arr_col)){
foreach($arr_col as $key1=>$val1){
$tmp_oo=get_db_msg("select sum(num) 'num' from ".$table_pre."order where uid='".$uid."' and color='".$val1."' and iid='".$khid."' and ka<>'y' and _key='".$_key."'");
$color_sl=$tmp_oo["num"]>0?$tmp_oo["num"]:0;
$str_color_num.="\"".$val1."\":\"".$color_sl."\",";
}
$str_color_num=substr($str_color_num,0,-1);
}
$json_data.="\"list_color\":{".$str_color_num."},";
}
break;
case "jd":
if($is_brand=="y"){
$con_brand="";
if($s_brand){
$arr_s_brand=explode(",",$s_brand);
for($i=0;$i<count($arr_s_brand);$i++){
$con_brand.="brand='".$arr_s_brand[$i]."' or ";
}
if($con_brand)
$con_brand=" and (".substr($con_brand,0,-3).")";
}
$q="update ".$table_pre."client_brand set is_jd='y' where cid='".$uid."'".$con_brand;
$db->query($q);
$url=$_SERVER["PHP_SELF"]."?_m=".$_m."&_a=o&s_tab=wcl";
//记录订单操作日志
update_order_state($uid,$uid,"交单","");
$json_data.="\"code\":101,";
/*if($jd2=="y"){
$con_brand="";
if($s_brand){
$arr_s_brand=explode(",",$s_brand);
for($i=0;$i<count($arr_s_brand);$i++){
$con_brand.="brand='".$arr_s_brand[$i]."' or ";
}
if($con_brand)
$con_brand=" and (".substr($con_brand,0,-3).")";
}
$q="update ".$table_pre."client_brand set is_jd='y' where cid='".$uid."'".$con_brand;
$db->query($q);
$url=$_SERVER["PHP_SELF"]."?_m=".$_m."&_a=o&s_tab=wcl";
//记录订单操作日志
update_order_state($uid,$uid,"交单","");
$json_data.="\"code\":101,";
//alert_and_redirect("订单提交成功,请等待客户经理确认!",$url);
}else{
//多品牌交单
//$url=$_SERVER["PHP_SELF"]."?_m=".$_m."&_a=o&s_tab=wcl";
//url_redirect($url);
}*/
}else{
//检查订货规则
$msg=check_dhgz_client($uid);
if($msg!="y"){
$json_data.="\"code\":0,\"msg\":\"".$msg."\",";
}else{
$q="update ".$table_pre."client set is_jd='y' where id='".$uid."'";
$db->query($q);
$url=$_SERVER[PHP_SELF]."?_m=".$_m.$link_var_brand;
//记录订单操作日志
update_order_state($uid,$uid,"交单","");
$json_data.="\"code\":101,";
}
//alert_and_redirect("订单提交成功,请等待客户经理确认!",$url);
}
break;
case "single":
$is_brand=is_brand();
$id=$khid;
$json_data.="\"sys_ck_input\":\"".$sys_ck_input."\",";
$json_data.="\"s_title\":\"".$s_title."\",";
$have_md="n";
$s_xh=deel_num($s_xh);
$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);
}else{
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
}
/*if($search_type=="xh"){
if($s_xh){
if($xh_ms=="2"){
//序号到色
$msg_kh_xh=get_db_msg("select * from ".$table_pre."kh_xh where xh='".$s_xh."' limit 0,1");
$q1="select count(*) 'num' from ".$table_pre."kh_xh where xh='".$s_xh."'";
$q2="select a.xh 'xh',b.no 'no',b.id 'id' from ".$table_pre."kh_xh a,".$table_pre."kh b where a.kh=b.no and a.xh='".$s_xh."'";
$msg=get_db_msg("select * from ".$table_pre."kh where no='".$msg_kh_xh["kh"]."' limit 0,1");
}else{
//序号查询定制
$msg=get_db_msg("select * from ".$table_pre."kh where xh='".$s_xh."' limit 0,1");
$q1="select count(*) 'num' from ".$table_pre."kh where xh='".$s_xh."'";
$q2="select xh,no,id from ".$table_pre."kh where xh='".$s_xh."'";
}
$_xh=$s_xh;
$m1=get_db_msg($q1);
}else{
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
$_xh=get_kh_xh($msg);
}
}else{
$s_no=trim($s_no);
if($s_no){
$msg=get_db_msg("select * from ".$table_pre."kh where no like '%".$s_no."%' limit 0,1");
$m1=get_db_msg("select count(*) 'num' from ".$table_pre."kh where no like '%".$s_no."%'");
if($xh_ms=="2")
$q2="select a.xh 'xh',b.no 'no',b.id 'id' from ".$table_pre."kh_xh a,".$table_pre."kh b where a.kh=b.no and b.no like '%".$s_no."%'";
else
$q2="select xh,no,id from ".$table_pre."kh where no like '%".$s_no."%'";
}else{
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
}
$_xh=get_kh_xh($msg);
}*/
$id=$msg["id"];
//单款历史数据
$q_ls="select * from ".$table_pre."plugin_jyl where no='".$msg["no"]."' and uid='".$uid."'";
$r_ls=$db->query($q_ls);
$arr_ls="";
while($m_ls=$db->fetch_array($r_ls)){
$arr_ls.="{\"color\":\"".$m_ls["color"]."-".get_cate_title_no("color",$m_ls["color"])."\",\"sl\":\"".$m_ls["jyl"]."\"},";
}
$arr_ls=substr($arr_ls,0,-1);;
$json_data.="\"color_jyl\":[".$arr_ls."],";
$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($str_title){
$str_title=deel_end($str_title);
$msg_err="存在以下符合条件的多个款:".$msg_err;
}
//echo_wrong("<div width=\"100%\" align=\"left\" style=\"line-height:25px;\">找到以下符合条件的多个款,请选择:<br>".$str_title."<div>");
}
//
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,";
$_xh=get_kh_xh($msg);
//判断是否存在规格
$is_ggk=is_ggk($msg["id"]);
$json_data.="\"is_ggk\":\"".$is_ggk."\",";
$json_data.="\"size_group_id\":\"".$msg["size_group"]."\",";
//判断代理
$dl_uid=get_dl_id($msg_login["path"]);
$is_jd_dl=$is_checked_dl="n";
if($dl_uid>0){
$msg_dl=get_db_msg("select * from ".$table_pre."client where id='".$dl_uid."'");
if($msg_dl["is_jd"]=="y")
$is_jd_dl="y";
if($msg_dl["is_checked"]=="y")
$is_checked_dl="y";
}
//检查是否是不予下单款
//取得客户等级
$client_dj=trim($msg_login["dj"]);
$con_dj=$client_dj?" and (dj='".$client_dj."' or dj='')":" and dj=''";
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='byxdk' and kh='".$msg["no"]."'".$con_dj);
$byxdk=$tmp["id"]>0?"y":"n";
//品牌控制
if($is_brand=="y"){
$msg_brand=get_db_msg("select * from ".$table_pre."client_brand where cid='".$uid."' and brand='".$msg["brand"]."'");
}
//-------------------设置禁止提交表单
if($order_close=="y" || $msg["ka"]=="y" || $msg_login["is_jd"]=="y" || $msg_login["is_checked"]=="y" || $msg_brand["is_jd"]=="y" || $msg_brand["is_checked"]=="y" || $is_checked_dl=="y" || $is_jd_dl=="y" || $byxdk=="y"){
$json_data.="\"state\":\"n\",";
$disable=" disabled";
}else{
$json_data.="\"state\":\"y\",";
$disable="";
}
if($is_brand=="y" && !$msg_brand["id"]){
$json_data.="\"state\":\"n\",";
$disable=" disabled";
}
//-------------------设置提示信息
//必定款
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='bdk' and kh='".$msg["no"]."'".$con_dj);
if($tmp["id"]>0)
$msg_tip="必定款:".$tmp["num"]."件|";
//起订量
$client_dj=trim($msg_login["dj"]);
$con_dj=$client_dj?" and (dj='".$client_dj."' or dj='')":" and dj=''";
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='qdl' and kh='".$msg["no"]."'".$con_dj);
if($tmp["id"]>0){
$tip1="";
$q1="select * from ".$table_pre."gz where cate='qdl' and kh='".$msg["no"]."'".$con_dj;
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
if($m1["color"])
$tip1.=$m1["color"]."-".get_cate_title_no("color",$m1["color"]).",".$m1["num"]."件;";
else
$tip1.="整款:".$m1["num"]."件;";
}
$msg_tip="起订量:".$tip1."|";
}
//必定款色
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='bdks' and kh='".$msg["no"]."'".$con_dj);
if($tmp["id"]>0){
$tip1="";
$q1="select * from ".$table_pre."gz where cate='bdks' and kh='".$msg["no"]."'".$con_dj;
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$tip1.=$m1["color"]."-".get_cate_title_no("color",$m1["color"]).",".$m1["num"]."件;";
}
$msg_tip.="必定款色:".$tip1."|";
}
//必定规格
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='bdgg' and kh='".$msg["no"]."'".$con_dj);
if($tmp["id"]>0){
$tip1="";
$q1="select * from ".$table_pre."gz where cate='bdgg' and kh='".$msg["no"]."'".$con_dj;
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$tip1.=$m1["color"]."-".get_cate_title_no("color",$m1["color"])."|".get_gg_title($m1["bc"]).",".$m1["num"]."件;";
}
$msg_tip.="必定".d_translate("gg").":".$tip1."|";
}
//订货倍数
$show_gg_zxs="n";
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='dhbs' and kh='".$msg["no"]."'");
if($tmp["id"]>0){
$arr_dhbs=array();
$tip1="";
$q1="select * from ".$table_pre."gz where cate='dhbs' and kh='".$msg["no"]."'";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
if($m1["bc"])
$tip1.=get_gg_title($m1["bc"]).",";
$tip1.=$m1["num"]."件;";
$arr_dhbs[$m1["bc"]]=$m1["num"];
}
if($tip1 && $is_ggk=="y")
$show_gg_zxs="y";
if($is_ggk=="n")
$msg_tip.=d_translate("dhbs").":".$tip1."|";
}
//最高订量
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='zgdl' and kh='".$msg["no"]."'");
if($tmp["id"]>0){
$tip1="";
$q1="select * from ".$table_pre."gz where cate='zgdl' and kh='".$msg["no"]."'";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
if($m1["color"])
$tip1.=$m1["color"]."-".get_cate_title_no("color",$m1["color"]).",";
$tip1.=$m1["num"]."件;";
}
$msg_tip.="最高订量:".$tip1."|";
}
//关联款
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='glk' and (kh='".$msg["no"]."' or color='".$msg["no"]."')".$con_dj);
if($tmp["id"]>0){
$msg_tip.="关联款:";
$kh_gl=($msg["no"]==$tmp["kh"])?$tmp["color"]:$tmp["kh"];
if($tmp["num"]==3){
$tip1=($msg["no"]==$tmp["kh"])?"该款要求订量大于等于":"该款要求订量小于等于";
$tip2="";
}else if($tmp["num"]==1){
$tip1="该款要求与";
$tip2=",只能选择一款来订货。";
}
//取得关联款订单
$tmp_num=get_db_msg("select sum(num) 'num' from ".$table_pre."order where uid='".$msg_login["id"]."' and no='".$kh_gl."' and _key='".$_key."'");
$msg_tip.=$tip1." ".$kh_gl."(".deel_num($tmp_num["num"])."件)".$tip2."|";
}
$msg_tip=deel_end($msg_tip);
//
if($msg["ka"]=="y")
$msg_tip="该款为删除款!";
if($byxdk=="y")
$msg_tip="不予下单款!";
if($msg_login["is_jd"]=="y" || $msg_brand["is_jd"]=="y")
$msg_tip="对不起,您的订单已经提交!";
if($msg_login["is_checked"]=="y" || $msg_brand["is_checked"]=="y")
$msg_tip="对不起,您的订单已经确认!";
if($is_jd_dl=="y")
$msg_tip="对不起,您的上级代理订单已经提交!";
if($is_checked_dl=="y")
$msg_tip="对不起,您的上级代理订单已经确认!";
if($is_brand=="y" && !$msg_brand["id"]){
$msg_tip.="对不起,您没有该品牌的订货权限!";
}
if($order_close=="y")
$msg_tip="对不起,暂时关闭订单功能!";
$json_data.="\"gz\":\"".$msg_tip."\",";
$json_data.="\"show_gg_zxs\":\"".$show_gg_zxs."\",";
$json_data.="\"pm_ms\":\"".$pm_ms."\",";
//取得评级
$msg_pj=get_db_msg("select * from ".$table_pre."client_pj where khid='".$id."' and cid='".$uid."'");
if($msg_pj["id"]>0){
$pj_remark=dhtmlchars($msg_pj["remark"]);
$race=$msg_pj["race"];
$pj_icon=get_pj_icon($race,$id,'big');
}else{
$pj_remark="";
$race=0;
$pj_icon=get_pj_icon($race,$id,'big');
}
$json_data.="\"khid\":\"".$msg["id"]."\",";
$json_data.="\"kh\":\"".$msg["no"]."\",";
$json_data.="\"ka\":\"".$msg["ka"]."\",";
$json_data.="\"xh\":\"".get_kh_xh($msg)."\",";
if($msg["size_group"]==$child_sizegroup_id){
//童装尺码异价
foreach($arr_child_bx as $bx1 => $size1){
$m1=get_db_msg("select id,price from ".$table_pre."size_bx where no='".$msg["no"]."' and bx='".$bx1."'");
if($m1["id"]>0){
$price_zk=get_price_zk($uid,$msg["id"],'',$bx1);
$str_price.=$bx1.": ".$m1["price"]."";
if($price_zk!=$m1["price"])
$str_price.=" / 结算价:".$price_zk."";
$str_price.="<br>";
}
}
}else{
$dp_price=get_price_dp($uid,$msg["id"]);
$str_price=deel_num($dp_price)."";
$price_zk=get_price_zk($uid,$msg["id"]);
if($price_zk!=$dp_price){
$str_price.=" / 结算价:".deel_num($price_zk)."";
}
//买断价
$tmp=get_db_msg("select id,price from ".$table_pre."kh_md where (dj='".$msg_login["dj"]."' or dj='') and kh='".$msg["no"]."' limit 0,1");
if($tmp["id"]>0){
$price_md=$tmp["price"]>0?$tmp["price"]:$price_zk;
$str_price.=" / ".d_translate("md")."价:".deel_num($price_md)."";
}
}
$json_data.="\"price\":\"".$str_price."\",";
$json_data.="\"this_disable\":\"".$disable."\",";
if(is_array($sys_color_zd) && count($sys_color_zd)>0){
//取得款色表的定制字段
$str_ds_h=$str_ds_b="";
$str_ds_h="{\"v\":\"颜色\"},";
//$other_info.="<table border=0 cellspacing=1 cellpadding=3 bgcolor='#cccccc'><tr bgcolor='#f0f0f0'><td>颜色</td>";
foreach($sys_color_zd as $k1 => $v1){
//$other_info.="<td>".$v1."</td>";
$str_ds_h.="{\"v\":\"".$v1."\"},";
}
$json_data.="\"ds_header\":[".deel_end($str_ds_h)."],";
//$other_info.="</tr>";
$q="select * from ".$table_pre."kh_color where iid='".$msg["id"]."' order by color";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$str_ds_b.="{\"color\":\"".$m["color"]."\",";
$tmpds="";
$tmpds.="{\"v\":\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\"},";
//$other_info.="<tr bgcolor='#ffffff'><td>".$m["color"]."-".get_cate_title_no("color",$m["color"])."</td>";
foreach($sys_color_zd as $k1 => $v1){
//$other_info.="<td align='center'>".$m[$k1]."</td>";
$tmpds.="{\"v\":\"".$m[$k1]."\"},";
}
//$other_info.="</tr>";
$str_ds_b.="\"v\":[".deel_end($tmpds)."]},";
}
$json_data.="\"ds_body\":[".deel_end($str_ds_b)."],";
//$other_info.="</table>";
}
$q="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and flag_bd='n' and no<>'jgd' and no<>'sx' and no<>'color' order by ord";
$r=$db->query($q);
$i=0;
$zds="";
while($m=$db->fetch_array($r)){
$str_select_dz.="\"".$m["title"]."|";
if($m["no"]=="zd1" || $m["no"]=="zd2" || $m["no"]=="zd3"){
//$str_select_dz.=$msg[$m["no"]]."\",";
//$zds.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
}else{
//$str_select_dz.=deel_js_var(get_cate_title_no($m["no"],$msg[$m["no"]]))."\",";
$zds.="{\"no\":\"".$i."\",\"title\":\"".get_cate_title_no("arr_select",$m["no"])."\",\"value\":\"".get_cate_title_no($m["no"],$msg[$m["no"]])."\"},";
}
$i++;
}
$zds=deel_end($zds);
$json_data.="\"zds\":[".$zds."],";
$json_data.="\"xj\":\"".$race."\",";
$json_data.="\"ksm\":\"".$msg["title"]."\",";
$json_data.="\"pjwz\":\"".$pj_remark."\",";
$arrBx=array();
$str_bx="";
if($msg["size_group"]==$bx_sizegroup_id){
//文胸
$r1=$db->query("select * from ".$table_pre."size_bx where no='".$msg["no"]."' order by bx");
$i1=0;
while($m1=$db->fetch_array($r1)){
$arrBx[$i1][]=$m1["bx"];
$str_bx.=$m1["bx"];
$arrBx[$i1][]=$m1["size"];
$i1++;
}
//取得尺码
$str_size="";
$r1=$db->query("select * from ".$table_pre."size where iid='".$bx_sizegroup_id."' order by no");
while($m1=$db->fetch_array($r1)){
$str_size.=$m1["no"].",";
}
$str_size=substr($str_size,0,-1);
$arr_size=explode(",",$str_size);
}else if($msg["size_group"]==$child_sizegroup_id){
//童装
$str_size=$str_bx=$str_bx_title=$str_size_tz="";
$arr_size_tmp=array();//童装所有尺码临时记录
$i1=$j1=0;
foreach($arr_child_bx as $bx1 => $arr_bx_size1){
$check_tmp=get_db_msg("select id,size,price from ".$table_pre."size_bx where no='".$msg["no"]."' and bx='".$bx1."'");
if($check_tmp["id"]>0){
$str_size_tz.=$i1."|".$check_tmp["size"].":";
$arr_tmp=explode(",",$check_tmp["size"]);
for($i2=0;$i2<count($arr_tmp);$i2++){
if(!in_array($arr_tmp[$i2],$arr_size_tmp)){
$arr_size_tmp[]=$arr_tmp[$i2];
}
}
$str_bx_title.=$bx1.",";
$str_bx.=$i1.",";
$arrBx[$j1][0]=$i1;
$arrBx[$j1][1]=$check_tmp["size"];
$j1++;
}
$i1++;
}
sort($arr_size_tmp);
//取得尺码
$arr_size=$arr_size_tmp;
$str_size=arr_to_str($arr_size);
}else{
if($is_ggk!="n"){
//$str_bx.=",";
$r1=$db->query("select gg from ".$table_pre."kh_gg where iid='".$msg["id"]."' group by gg order by gg");
$i1=0;
while($m1=$db->fetch_array($r1)){
$str_bx.=$m1["gg"].",";
$i1++;
}
}
$arrBx[0][0]="";
$arrBx[0][1]=$msg["size"];
$arr_size=explode(",",$msg["size"]);
}
if($str_bx)
$str_bx=substr($str_bx,0,-1);
if($str_bx_title)
$str_bx_title=substr($str_bx_title,0,-1);
if($str_size_tz)
$str_size_tz=substr($str_size_tz,0,-1);
$arr_color=explode(",",$msg["color"]);
if(!$color){
if($msg["main_pic"])
$color=$msg["main_pic"];
}
//print_r($arrBx);
$arr_color_ka=explode(",",$msg["color_ka"]);
$total=0;
$js_check_str="";
//取得数量
$str_num="";
$input_width=get_input_width(count($arr_size));
$num_var="[\"".$input_width."\"]";
$json_data.="\"input_width\":\"".$input_width."\",";
$num_arr="";
//判断是否采用服装版本下单
$is_xd_clothes="y";
$msg_size_group=get_db_msg("select title from ".$table_pre."keyword where cate='size' and id='".$msg["size_group"]."'");
if(in_array($msg_size_group["title"],$sys_size_group_xz))
$is_xd_clothes="n";
$json_data.="\"is_xd_clothes\":\"".$is_xd_clothes."\",";
//print_r($arrBx);
if($is_xd_clothes=="y"){
for($i=0;$i<count($arr_color);$i++){
//判断是否为有规则搭配
$check=get_db_msg("select zsh from ".$table_pre."kh_dp where kh='".$msg["no"]."' and color='".$arr_color[$i]."' and gz<>''");
$colorka="n";
if(in_array($arr_color[$i],$arr_color_ka,true)){
$disable_color=" disabled";
$sty1="font-weight:bold;color:#ff0000;";
$link_ds="";
$colorka="y";
}else if($check["zsh"]>0){
$disable_color=" disabled";
$sty1="";
//$link_ds=" <a href='?_m=dp_single&zsh=".$check["zsh"]."&rurl=".urlencode($this_url)."'><span style='color:#0000ff;'>进入搭配订货</span></a>";
$link_ds=$check["zsh"];
}else{
$sty1="";
$disable_color=$disable;
$link_ds="";
}
$tr_bg=($color==$arr_color[$i])?"#d3d2d1":"#ffffff";
$strarr="";
if($is_ggk!="n"){
//有规格
$r1=$db->query("select * from ".$table_pre."kh_gg where iid='".$msg["id"]."' and color='".$arr_color[$i]."' order by ord");
$i1=0;
$arr_gg=array();
while($m1=$db->fetch_array($r1)){
$arr_gg[$i1]["title"]=$m1["gg"];
if($is_ggk=="y"){
foreach($sys_gg_zd as $k1 => $v1){
$arr_gg[$i1][$k1]=$m1[$k1];
}
}
$i1++;
}
//$num_arr.="[\"".$tr_bg."\",\"".count($arr_gg)."\",\"".$link_ds."\",\"".$sty1."\",\"1|".$arr_color[$i]."-".get_cate_title_no("color",$arr_color[$i])."\",";
$num_arr.="{\"tr_bg\":\"".$tr_bg."\",\"ggs\":\"".count($arr_gg)."\",\"ka\":\"".$colorka."\",\"link_ds\":\"".$link_ds."\",\"sty1\":\"".$sty1."\",\"disable_color\":\"".$disable_color."\",";
$strarr.="{\"no\":\"1\",\"id\":\"color_td_".$arr_color[$i]."\",\"value\":\"".$arr_color[$i]."-".get_cate_title_no("color",$arr_color[$i])."\"},";
if($i1==0){
$arr_gg[0]["title"]="";
if($is_ggk=="y"){
foreach($sys_gg_zd as $k1 => $v1){
$arr_gg[0][$k1]="";
}
}
}
for($j1=0;$j1<count($arr_gg);$j1++){
$strarr1="";
$s_xj=0;
if($j1>0)
$num_arr.="{\"tr_bg\":\"".$tr_bg."\",\"ggs\":\"1\",\"link_ds\":\"\",\"sty1\":\"".$sty1."\",\"disable_color\":\"".$disable_color."\",";
//$num_arr.="\"1|".get_gg_title($arr_gg[$j1]["title"])."\",";
$strarr1.="{\"no\":\"1\",\"id\":\"color_td_".get_gg_title($arr_gg[$j1]["title"])."\",\"value\":\"".get_gg_title($arr_gg[$j1]["title"])."\"},";
if($is_ggk=="y"){
foreach($sys_gg_zd as $k1 => $v1){
//$num_arr.="\"1|".$arr_gg[$j1][$k1]."\",";
$strarr1.="{\"no\":\"1\",\"id\":\"color_td_".$arr_gg[$j1][$k1]."\",\"value\":\"".$arr_gg[$j1][$k1]."\"},";
}
}
if($show_gg_zxs=="y")
$strarr1.="{\"no\":\"1\",\"id\":\"color_td_".get_main_value1($arr_dhbs,$arr_gg[$j1]["title"])."\",\"value\":\"".get_main_value1($arr_dhbs,$arr_gg[$j1]["title"])."\"},";
if($pm_ms!="n")
$strarr1.="{\"no\":\"2\",\"id\":\"pm_".$arr_color[$i]."_".$arr_gg[$j1]["title"]."\",\"value\":\"pm_".$arr_color[$i]."_".$arr_gg[$j1]["title"]."\"},";
$j=0;
for($k=0;$k<count($arr_size);$k++){
$num1=get_order_num($id,$arr_color[$i],$arr_gg[$j1]["title"],$arr_size[$k]);
$js_check_str.=$num1.",";
if(check_md($msg["no"],$arr_color[$i],$arr_gg[$j1]["title"],$arr_size[$k],$msg_login["dj"])=="n"){
$bg_input_num="#ffffff";
}else{
$bg_input_num="#00ff00";
$have_md="y";
}
if(check_size_not($msg["no"],$arr_color[$i],$arr_gg[$j1]["title"],$arr_size[$k])=="y"){
$disable_color1=" disabled";
$bg_input_num1="#cccccc";
}else{
$disable_color1=$disable_color;
$bg_input_num1=$bg_input_num;
}
$arr_size_check=$arr_size;
if(in_array($arr_size[$k],$arr_size_check)){
$strarr1.="{\"no\":\"3\",\"id\":\"num_".$arr_color[$i]."_".$arr_gg[$j1]["title"]."_".$arr_size[$k]."\",\"value\":\"".$num1."\",\"bg\":\"".$bg_input_num1."\",\"disable\":\"".$disable_color1."\"},";
}else{
$strarr1.="{\"no\":\"1\",\"id\":\"\",\"value\":\"&nbsp;\"},";
}
//合计尺码数量
$var_xj_size="xj_size_".$arr_size[$k];
//if($disable_color1==""){
$s_xj+=$num1;
$$var_xj_size+=$num1;
//}
$j++;
}
$total+=$s_xj;
$strarr1.="{\"no\":\"4\",\"id\":\"xj_".$arr_color[$i]."_".$arr_gg[$j1]["title"]."\",\"value\":\"".$s_xj."\"},";
//$strarr.=",";
//$strarr=substr($strarr,0,-1);
$num_arr.="\"dt\":[".deel_end($strarr.$strarr1)."]},";
}
}else{
//无规格
$num_arr.="{\"tr_bg\":\"".$tr_bg."\",\"ggs\":\"".count($arrBx)."\",\"ka\":\"".$colorka."\",\"link_ds\":\"".$link_ds."\",\"sty1\":\"".$sty1."\",";
$strarr.="{\"no\":\"1\",\"id\":\"color_td_".$arr_color[$i]."\",\"value\":\"".$arr_color[$i]."-".get_cate_title_no("color",$arr_color[$i])."\"},";
//$num_arr.="[\"".$tr_bg."\",\"".count($arrBx)."\",\"".$link_ds."\",\"".$sty1."\",\"1|".$arr_color[$i]."-".get_cate_title_no("color",$arr_color[$i])."\",";
//$j1=0;
//foreach($arrBx as $tmp_bx => $tmp_size){
for($j1=0;$j1<count($arrBx);$j1++){
$tmp_bx=$arrBx[$j1][0];
$tmp_size=$arrBx[$j1][1];
if($msg["size_group"]==$child_sizegroup_id){
$bx_title=get_child_bx_title($tmp_bx);
}else if($msg["size_group"]==$bx_sizegroup_id){
$bx_title=$tmp_bx;
}else{
$tmp_bx=deel_0($tmp_bx);
$bx_title=$tmp_bx;
}
$strarr1="";
$s_xj=0;
if($j1>0)
$num_arr.="{\"tr_bg\":\"".$tr_bg."\",\"ggs\":\"1\",\"link_ds\":\"\",\"sty1\":\"".$sty1."\",";
if($msg["size_group"]==$bx_sizegroup_id)
$strarr1.="{\"no\":\"1\",\"id\":\"color_td_".$tmp_bx."\",\"value\":\"".$tmp_bx."\"},";
else if($msg["size_group"]==$child_sizegroup_id)
$strarr1.="{\"no\":\"1\",\"id\":\"color_td_".$bx_title."\",\"value\":\"".$bx_title."\"},";
if($pm_ms!="n")
$strarr1.="{\"no\":\"2\",\"id\":\"pm_".$arr_color[$i]."_".$tmp_bx."\",\"value\":\"pm_".$arr_color[$i]."_".$tmp_bx."\"},";
$j=0;
for($k=0;$k<count($arr_size);$k++){
$num1=get_order_num($id,$arr_color[$i],$bx_title,$arr_size[$k]);
if(check_md($msg["no"],$arr_color[$i],$bx_title,$arr_size[$k],$msg_login["dj"])=="n"){
$bg_input_num="#ffffff";
}else{
$bg_input_num="#00ff00";
$have_md="y";
}
if(check_size_not($msg["no"],$arr_color[$i],$bx_title,$arr_size[$k])=="y"){
$disable_color1=" disabled";
$bg_input_num1="#cccccc";
}else{
$disable_color1=$disable_color;
$bg_input_num1=$bg_input_num;
}
if($msg["size_group"]==$bx_sizegroup_id){
$arr_size_check=explode(",",$tmp_size);
}else if($msg["size_group"]==$child_sizegroup_id){
$tmp=get_db_msg("select id,size from ".$table_pre."size_bx where no='".$msg["no"]."' and bx='".$bx_title."'");
if($tmp["id"]>0)
$arr_size_check=explode(",",$tmp["size"]);
else
$arr_size_check=array();
}else{
$arr_size_check=$arr_size;
}
if(in_array($arr_size[$k],$arr_size_check)){
$strarr1.="{\"no\":\"3\",\"id\":\"num_".$arr_color[$i]."_".$tmp_bx."_".$arr_size[$k]."\",\"value\":\"".$num1."\",\"bg\":\"".$bg_input_num1."\",\"disable\":\"".$disable_color1."\"},";
$js_check_str.=$num1.",";
}else{
$strarr1.="{\"no\":\"1\",\"id\":\"\",\"value\":\"&nbsp;\"},";
}
//合计尺码数量
$var_xj_size="xj_size_".$arr_size[$k];
//if($disable_color1==""){
$s_xj+=$num1;
$$var_xj_size+=$num1;
//}
$j++;
}
$total+=$s_xj;
$strarr1.="{\"no\":\"4\",\"id\":\"xj_".$arr_color[$i]."_".$tmp_bx."\",\"value\":\"".$s_xj."\"},";
//$strarr=substr($strarr,0,-1);
$num_arr.="\"dt\":[".deel_end($strarr.$strarr1)."]},";
//$j1++;
}//
}
/*if($j1==0)
$num_arr.=",";*/
}
}else{
//取得装箱数
$q1="select num from ".$table_pre."gz where cate='zxs' and (dj='".$msg_login["username"]."' or dj='') and kh='".$msg["no"]."' order by num";
//echo $q1;
$r1=$db->query($q1);
$sql_pm="";
$str_zxs="";
while($m1=$db->fetch_array($r1)){
$sql_pm.="num='".$m1["num"]."' or ";
//$str_zxs.="{\"zxs\":\"".$m1["num"]."\"},";
$str_zxs.=$m1["num"].",";
}
if($str_zxs){
$str_zxs=deel_end($str_zxs);
}
$json_data.="\"zxs\":\"".$str_zxs."\",";
$total_xs=$total_num=0;
if($is_ggk!="n"){
//有规格数据
$q1="select * from ".$table_pre."kh_gg where iid='".$msg["id"]."' order by color,gg";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
//判断是否为有规则搭配
$check=get_db_msg("select zsh from ".$table_pre."kh_dp where kh='".$msg["no"]."' and color='".$m1["color"]."' and gz<>''");
if(in_array($m1["color"],$arr_color_ka)){
$is_ka="y";
}else{
$is_ka="n";
}
$is_selected=($color==$m1["color"])?"y":"n";
//取得该颜色的配码信息
$q2="select * from ".$table_pre."order_pm where _key='".$sys_this_order_flag."' and uid='".$uid."' and iid='".$msg["id"]."' and color='".$m1["color"]."' and bx='".$m1["gg"]."' order by id";
$r2=$db->query($q2);
$j1=0;
$strpm="";
while($m2=$db->fetch_array($r2)){
$tmp=get_db_msg("select title,gz from ".$table_pre."size_pm where id='".$m2["pmid"]."'");
$tmp_num=$m2["xs"]*count_pm_num($tmp["gz"]);
//$num_arr.="[\"".$m1["color"]."|".get_cate_title_no("color",$m1["color"])."|".$m1["gg"]."|".get_gg_title($m1["gg"])."\",".$j1.",\"".$tmp["title"]."|".$tmp["gz"]."\",".$m2["xs"].",\"".$is_ka."\",\"".$is_selected."\"],";
$strpm.="{\"xh\":\"".$j1."\",\"pmt\":\"".$tmp["title"]."\",\"pm\":\"".$tmp["gz"]."\",\"xs\":".$m2["xs"].",\"num\":".$tmp_num."},";
$total_xs+=$m2["xs"];
$total_num+=$tmp_num;
$j1++;
}
if($j1==0){
$str_color_hang.=($j1+1).",";
$j1++;
//$num_arr.="[\"".$m1["color"]."|".get_cate_title_no("color",$m1["color"])."|".$m1["gg"]."|".get_gg_title($m1["gg"])."\",0,\"|\",0,\"".$is_ka."\",\"".$is_selected."\"],";
}else{
$str_color_hang.=($j1).",";
}
$num_arr.="{\"color\":\"".$m1["color"]."\",\"colort\":\"".get_cate_title_no("color",$m1["color"])."\",\"gg\":\"".$m1["gg"]."\",\"ggt\":\"".get_gg_title($m1["gg"])."\",\"is_ka\":\"".$is_ka."\",\"is_selected\":\"".$is_selected."\",\"count\":\"".$j1."\",\"arr_pm\":[".deel_end($strpm)."]},";
$str_color.=$m1["color"]."_".$m1["gg"].",";
}
$colspan1=4+count($arr_size);
}else{
for($i=0;$i<count($arr_color);$i++){
//判断是否为有规则搭配
$check=get_db_msg("select zsh from ".$table_pre."kh_dp where kh='".$msg["no"]."' and color='".$arr_color[$i]."' and gz<>''");
if(in_array($arr_color[$i],$arr_color_ka)){
$is_ka="y";
}else{
$is_ka="n";
}
$is_selected=($color==$arr_color[$i])?"y":"n";
//取得该颜色的配码信息
$q1="select * from ".$table_pre."order_pm where _key='".$sys_this_order_flag."' and uid='".$uid."' and iid='".$msg["id"]."' and color='".$arr_color[$i]."' order by id";
$r1=$db->query($q1);
$j1=0;
$strpm="";
while($m1=$db->fetch_array($r1)){
$tmp=get_db_msg("select title,gz from ".$table_pre."size_pm where id='".$m1["pmid"]."'");
$tmp_num=$m1["xs"]*count_pm_num($tmp["gz"]);
//$num_arr.="[\"".$arr_color[$i]."|".get_cate_title_no("color",$arr_color[$i])."||\",".$j1.",\"".$tmp["title"]."|".$tmp["gz"]."\",".$m1["xs"].",\"".$is_ka."\",\"".$is_selected."\"],";
$strpm.="{\"xh\":\"".$j1."\",\"pmt\":\"".$tmp["title"]."\",\"pm\":\"".$tmp["gz"]."\",\"xs\":".$m1["xs"].",\"num\":".$tmp_num."},";
$total_xs+=$m1["xs"];
$total_num+=$m1["xs"]*count_pm_num($tmp["gz"]);
$j1++;
}
if($j1==0){
$str_color_hang.=($j1+1).",";
$j1++;
//$num_arr.="[\"".$arr_color[$i]."|".get_cate_title_no("color",$arr_color[$i])."||\",0,\"|\",0,\"".$is_ka."\",\"".$is_selected."\"],";
}else{
$str_color_hang.=($j1).",";
}
$num_arr.="{\"color\":\"".$arr_color[$i]."\",\"colort\":\"".get_cate_title_no("color",$arr_color[$i])."\",\"gg\":\"\",\"ggt\":\"\",\"is_ka\":\"".$is_ka."\",\"is_selected\":\"".$is_selected."\",\"count\":\"".$j1."\",\"arr_pm\":[".deel_end($strpm)."]},";
$str_color.=$arr_color[$i]."_,";
}
$colspan1=3+count($arr_size);
}
$json_data.="\"total_xs\":".$total_xs.",";
$json_data.="\"total_num\":".$total_num.",";
/*$str_size_title="";
$arr_size_title=array();
for($i=0;$i<count($arr_size);$i++){
$tmp=get_db_msg("select title from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$arr_size[$i]."'");
$str_size_title.=$arr_size[$i]."|".$tmp["title"].",";
$arr_size_title[$i]=$tmp["title"];
}
if($str_size_title)
$str_size_title=substr($str_size_title,0,-1);
//内容
$content_num.=$str_num;*/
$hj_arr="[]";
$pm_op="[]";
if($js_check_str)
$js_check_str=substr($js_check_str,0,-1);
//echo $num_arr;
//取得配码的行数
$tmp1=get_db_msg("select count(*) 'num' from ".$table_pre."size_pm where uid='".$uid."' and pm_dj='".$msg["pm_dj"]."'");
$pm_rows=$tmp1["num"];
$json_data.="\"pm_rows\":".$pm_rows.",";
}
$num_arr=substr($num_arr,0,-1);
$json_data.="\"dds\":[".$num_arr."],";
//----------------数量表
//表头
$str_size_title=$cmz="";
for($i=0;$i<count($arr_size);$i++){
$tmp=get_db_msg("select title from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$arr_size[$i]."'");
$str_size_title.=$arr_size[$i]."|".$tmp["title"].",";
$cmz.="{\"no\":\"".$arr_size[$i]."\",\"title\":\"".$tmp["title"]."\"},";
}
if($str_size_title)
$str_size_title=substr($str_size_title,0,-1);
$json_data.="\"str_size_title\":\"".$str_size_title."\",";
$cmz=deel_end($cmz);
$json_data.="\"cmz\":[".$cmz."],";
//内容
$content_num.=$str_num;
//合计
if($is_xd_clothes=="y"){
$colspan1=1;
if($is_ggk=="y")
$colspan1+=count($sys_gg_zd)+1;
else if($is_ggk=="b")
$colspan1+=1;
if($msg["size_group"]==$bx_sizegroup_id || $msg["size_group"]==$child_sizegroup_id)
$colspan1++;
if($pm_ms!="n")
$colspan1++;
if($show_gg_zxs=="y")
$colspan1++;
}
$json_data.="\"colspan1\":\"".$colspan1."\",";
if($is_xd_clothes=="y"){
$hj_arr="";
for($i=0;$i<count($arr_size);$i++){
$var_xj_size="xj_size_".$arr_size[$i];
$hj_arr.="{\"id\":\"".$arr_size[$i]."\",\"size\":\"".$$var_xj_size."\"},";
}
$hj_arr=deel_end($hj_arr);
}
$json_data.="\"hj_arr\":[".$hj_arr."],";
if($js_check_str)
$js_check_str=substr($js_check_str,0,-1);
$json_data.="\"js_check_str\":\"".$js_check_str."\",";
//定义图片目录
$pathdir="../attachments/design/mini";
if($flag_pad=="_pad"){
$s_pathdir_mini="content://com.muchuang.edt/attachments/design/mini";
$s_pathdir_big="content://com.muchuang.edt/attachments/design/big";
}else{
$s_pathdir_mini="../attachments/design/mini";
$s_pathdir_big="../attachments/design/big";
}
//--取得单款图片数组
$str_pic_big="";
$arr_pic="";
if($sys_close_image=="y"){
$pic_m1="images/no_pic.png";
$pic_b1="images/no_pic_big.png";
$arr_pic.="{\"pic\":\"".$pic_m1."\",\"pic_w\":,\"pic_h\":,\"pic_big\":\"".$pic_b1."\",\"pic_big_w\":,\"pic_big_h\":},";
$str_pic_big.="images/no_pic_big.png";
}else{
if(is_file($pathdir."/".$msg["no"].".jpg")){
$pic_m1=$s_pathdir_mini."/".$msg["no"].".jpg";
$pic_b1=$s_pathdir_big."/".$msg["no"].".jpg";
//$arr_pic.="\"|".$pic_m1."|".str_replace("\"",",",out_good_pic_set($pic_m1,30,30))."|".$pic_b1."|".str_replace("\"",",",out_good_pic_set($pic_b1,$tmpl_order_single_w,$tmpl_order_single_h))."\",";
$tmppic=out_good_pic_set_arr($pic_m1,30,30);
$tmppic1=out_good_pic_set_arr($pic_b1,$tmpl_order_single_w,$tmpl_order_single_h);
$arr_pic.="{\"pic\":\"".$pic_m1."\",\"pic_w\":".$tmppic[0].",\"pic_h\":".$tmppic[1].",\"pic_big\":\"".$pic_b1."\",\"pic_big_w\":".$tmppic1[0].",\"pic_big_h\":".$tmppic1[1]."},";
$str_pic_big.=$pic_b1.",";
}
for($i=0;$i<count($arr_color);$i++){
if(is_file($pathdir."/".$msg["no"]."_".$arr_color[$i].".jpg")){
$pic_m1=$s_pathdir_mini."/".$msg["no"]."_".$arr_color[$i].".jpg";
$pic_b1=$s_pathdir_big."/".$msg["no"]."_".$arr_color[$i].".jpg";
//$arr_pic.="\"".$arr_color[$i]."|".$pic_m1."|".str_replace("\"",",",out_good_pic_set($pic_m1,40,40))."|".$pic_b1."|".str_replace("\"",",",out_good_pic_set($pic_b1,$tmpl_order_single_w,$tmpl_order_single_h))."\",";
$tmppic=out_good_pic_set_arr($pic_m1,40,40);
$tmppic1=out_good_pic_set_arr($pic_b1,$tmpl_order_single_w,$tmpl_order_single_h);
$arr_pic.="{\"color\":\"".$arr_color[$i]."\",\"pic\":\"".$pic_m1."\",\"pic_w\":".$tmppic[0].",\"pic_h\":".$tmppic[1].",\"pic_big\":\"".$pic_b1."\",\"pic_big_w\":".$tmppic1[0].",\"pic_big_h\":".$tmppic1[1]."},";
$str_pic_big.=$pic_b1.",";
}
}
}
$arr_pic=deel_end($arr_pic);
$json_data.="\"pics\":[".$arr_pic."],";
if($str_pic_big)
$str_pic_big=substr($str_pic_big,0,-1);
$json_data.="\"str_pic_big\":\"".$str_pic_big."\",";
//--取得产品细节图
$arr_detail="";
if(check_table_exist($table_pre."pic_detail")=="y"){
$q1="select pic from ".$table_pre."pic_detail where kh='".$msg["no"]."' order by pic";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$f=$s_pathdir_mini."/".$m1["pic"];
$f1=$s_pathdir_big."/".$m1["pic"];
$tmpdel=out_good_pic_set_arr($pathdir."/".$m1["pic"],120,120);
$arr_detail.="{\"pic\":\"".$f1."\",\"pic_big\":\"".$f."\",\"pic_w\":".$tmpdel[0].",\"pic_h\":".$tmpdel[1]."},";
$i++;
}
}
$arr_detail=substr($arr_detail,0,-1);
$json_data.="\"xjs\":[".$arr_detail."],";
//--搭配款
$arr_dpk="";
$no_str=trim($msg["dpk"]);
if($no_str){
$arr1=explode(",",$no_str);
for($i=0;$i<count($arr1);$i++){
if($arr1[$i]!=$msg["no"]){
$m1=get_db_msg("select id,no,xh,main_pic,color from ".$table_pre."kh where no='".$arr1[$i]."' limit 0,1");
if($m1["id"]>0){
$con_xh=$s_xh?"&s_xh=".$m1["xh"]:"";
$pic=get_kh_picture($m1["no"],$m1["main_pic"],$m1["color"],$flag_pad_offline);
$t=get_kh_xh($m1)."#".$m1["no"];
$tmpdpk=out_good_pic_set_arr($pic,90,120);
$arr_dpk.="{\"id\":\"".$m1["id"]."\",\"pic\":\"".$pic."\",\"pic_w\":".$tmpdpk[0].",\"pic_h\":".$tmpdpk[1].",\"title\":\"".$t."\"},";
$j++;
}
}
}
}
$arr_dpk=substr($arr_dpk,0,-1);
$json_data.="\"dpks\":[".$arr_dpk."],";
//--取得相关搭配
$arr_dp="";
$q1="select zsh,title,pic from ".$table_pre."kh_dp where kh='".$msg["no"]."' group by zsh order by zsh";
$r1=$db->query($q1);
$i=0;
while($m1=$db->fetch_array($r1)){
$pic=get_kh_dp_mini($m1["pic"],$flag_pad_offline);
$tmpdp=out_good_pic_set_arr($pic,90,120);
$arr_dp.="{\"zsh\":\"".$m1["zsh"]."\",\"pic\":\"".$pic."\",\"pic_w\":".$tmpdp[0].",\"pic_h\":".$tmpdp[1].",\"title\":\"".$m1["title"]."\"},";
$i++;
}
$arr_dp=substr($arr_dp,0,-1);
$json_data.="\"dps\":[".$arr_dp."],";
//--取得相关陈列
$q="select * from ".$table_pre."kh_cl where kh='".$msg["no"]."' group by zsh";
$r=$db->query($q);
$arr_cl="";
while($m=$db->fetch_array($r)){
$p_big=get_kh_cl_big($m["pic"],$flag_pad_offline);
$href1="?_m=cl_single&s_zsh=".$m["zsh"]."&rurl_cl_list=".urlencode($this_url);
$pic=get_kh_cl_mini($m["pic"],$flag_pad_offline);
$tmpcl=out_good_pic_set_arr($pic,150,112);
$arr_cl.="{\"zsh\":\"".$m["zsh"]."\",\"pic\":\"".$pic."\",\"pic_w\":".$tmpcl[0].",\"pic_h\":".$tmpcl[1].",\"title\":\"".$m["title"]."".$m["ord"]."\"},";
}
$arr_cl=substr($arr_cl,0,-1);
$json_data.="\"cls\":[".$arr_cl."],";
//--取得相关橱窗
$q="select * from ".$table_pre."kh_cc where kh='".$msg["no"]."' group by zsh";
$r=$db->query($q);
$arr_cc="";
while($m=$db->fetch_array($r)){
$p_big=get_kh_cc_big($m["pic"],$flag_pad_offline);
$href1="?_m=cc_single&zsh=".$m["zsh"]."&rurl=".urlencode($this_url);
$pic=get_kh_cc_mini($m["pic"],$flag_pad_offline);
$tmpcc=out_good_pic_set_arr($pic,150,112);
$arr_cc.="{\"zsh\":\"".$m["zsh"]."\",\"pic\":\"".$pic."\",\"pic_w\":".$tmpcc[0].",\"pic_h\":".$tmpcc[1].",\"title\":\"".$m["title"]."\"},";
}
$arr_cc=substr($arr_cc,0,-1);
$json_data.="\"ccs\":[".$arr_cc."],";
//
if($first_act)
$js_onload=" onload=\"".$first_act."\"";
//$json_data.="\"js_onload\":\"".$js_onload."\",";
//上一款、下一款
if($xh_ms=="2"){
$pre_xh=get_db_msg("select b.id 'id' from ".$table_pre."kh_xh a,".$table_pre."kh b where a.kh=b.no and a.xh<'".$_xh."' and a.kh<>'".$msg["no"]."' order by a.xh desc limit 0,1");
$next_xh=get_db_msg("select b.id 'id' from ".$table_pre."kh_xh a,".$table_pre."kh b where a.kh=b.no and a.xh>'".$_xh."' and a.kh<>'".$msg["no"]."' order by a.xh limit 0,1");
}else{
$pre_xh=get_db_msg("select id from ".$table_pre."kh where xh<'".$_xh."' and no<>'".$msg["no"]."' order by xh desc limit 0,1");
$next_xh=get_db_msg("select id from ".$table_pre."kh where xh>'".$_xh."' and no<>'".$msg["no"]."' order by xh limit 0,1");
}
$str_sxk="[\"".$pre_xh["id"]."\",\"".$next_xh["id"]."\"]";
$json_data.="\"prev\":\"".$pre_xh["id"]."\",";
$json_data.="\"next\":\"".$next_xh["id"]."\",";
$str_color=$msg["color"];
$json_data.="\"str_color\":\"".$str_color."\",";
//取得尺码组名称
$tmp=get_db_msg("select title from ".$table_pre."keyword where id='".$msg["size_group"]."'");
$size_group_title=$tmp["title"];
$json_data.="\"size_group_title\":\"".$size_group_title."\",";
if($is_xd_clothes=="y"){
//取得配码信息
$arr_bx_title=explode(",",$str_bx_title);
if($pm_ms!="n"){
$qy_uid=get_qy_id($msg_login["path"]);
$dl_uid=get_dl_id($msg_login["path"]);
if($msg["size_group"]==$child_sizegroup_id){
//童装配码规则,如果启用后台配码,并且有配码,只能配码输入。
$default_pm_id=0;
$default_pm="";
//取得所有适合我的配码
$pm_op="";
$i=0;
foreach($arr_child_bx as $bx1 => $arr_bx_size1){
if(in_array($bx1,$arr_bx_title)){
$con1="bx='".$bx1."' and ((uid='0' and dlid=0 and qyid=0) or (uid='0' and dlid=0 and qyid='".$qy_uid."') or (uid='0' and dlid='".$dl_uid."') or (uid='".$uid."')) and (khid='".$msg["id"]."' or (khid='0' and size_group_id='".$msg["size_group"]."'))";
$str_pm1="";
$m=get_db_msg("select id,title,gz from ".$table_pre."size_pm where ".$con1." order by uid desc,dlid desc,qyid desc,size_group_id desc limit 0,1");
if($m["id"]>0)
$pm_op.="{\"xh\":\"".$i."\",\"bx\":\"".$bx1."\",\"gz\":\"".$m["gz"]."\",\"title\":\"".$m["title"]."\",\"id\":\"".$m["id"]."\"},";
else
$pm_op.="{\"xh\":\"".$i."\",\"bx\":\"".$bx1."\",\"gz\":\"\",\"title\":\"\",\"id\":\"\"},";
}
$i++;
}
$pm_op=substr($pm_op,0,-1);
}else{
//默认匹配规则
$default_pm_id=0;
$default_pm="";
//取得所有适合我的配码
$pm_op="";
$pm_op_value=$default_pm_id;
$con1="((uid='0' and dlid=0 and qyid=0) or (uid='0' and dlid=0 and qyid='".$qy_uid."') or (uid='0' and dlid='".$dl_uid."') or (uid='".$uid."')) and (khid='".$msg["id"]."' or (khid='0' and size_group_id='".$msg["size_group"]."'))";
$q="select id,title,gz from ".$table_pre."size_pm where ".$con1." order by uid desc,dlid desc,qyid desc,size_group_id desc,id desc";
$r=$db->query($q);
$i=0;
while($m=$db->fetch_array($r)){
$pm_op.="{\"gz\":\"".$m["gz"]."\",\"title\":\"".$m["title"]."\",\"id\":\"".$m["id"]."\"},";
if($i==0){
$default_pm_id=$m["id"];
$default_pm=$m["gz"];
}
$i++;
}
/*if($i==0)
$pm_op.="\"|-暂无配码规则-|\",";*/
$pm_op=substr($pm_op,0,-1);
$str_pm_num=$str_pm_gz="";
if($default_pm){
$str_pm_gz=$default_pm;
$num_pm=0;
$arr1=explode(":",$default_pm);
for($i=0;$i<count($arr1);$i++){
$num_pm+=$arr1[$i];
}
if($num_pm>0)
$str_pm_num="=".$num_pm;
}
$pg_gz_w=count($arr_size)*13;
$content_pm="";
}
}
}
$json_data.="\"total\":\"".$total."\",";
$json_data.="\"translate_xh\":\"".d_translate("xh")."\",";
$json_data.="\"translate_gg\":\"".d_translate("gg")."\",";
$json_data.="\"translate_dhbs\":\"".d_translate("dhbs")."\",";
$json_data.="\"translate_dpk\":\"".d_translate("dpk")."\",";
$json_data.="\"translate_xgdp\":\"".d_translate("xgdp")."\",";
$json_data.="\"this_pm\":\"".$default_pm."\",";
$json_data.="\"default_pm\":\"".$default_pm."\",";
$json_data.="\"pmkg\":\"".$pm_ms."\",";
$json_data.="\"pg_gz_w\":\"".$pg_gz_w."\",";
$json_data.="\"str_pm_gz\":\"".$str_pm_gz."\",";
$json_data.="\"str_pm_num\":\"".$str_pm_num."\",";
$json_data.="\"pms\":[".$pm_op."],";
//include_once $path_dz."/dp/order_single.php";
update_log_hd();
}
break;
case "save":
$errmsg="";
if($order_close=="y"){
//alert_and_back("订单保存失败,原因是系统订单已经关闭!");
$errmsg="订单保存失败,原因是系统订单已经关闭!";
}
if($msg_login["is_jd"]=="y" && !$errmsg){
//alert_and_back("订单保存失败,原因是本用户订单已经提交!");
$errmsg="订单保存失败,原因是本用户订单已经提交!";
}
if($msg_login["is_checked"]=="y" && !$errmsg){
//alert_and_back("订单保存失败,原因是本用户订单已经确认!");
$errmsg="订单保存失败,原因是本用户订单已经确认!";
}
//判断代理
$dl_uid=get_dl_id($msg_login["path"]);
if($dl_uid>0){
$msg_dl=get_db_msg("select * from ".$table_pre."client where id='".$dl_uid."'");
if($msg_dl["is_jd"]=="y" && !$errmsg){
//alert_and_back("订单保存失败,原因是您的代理已经提交!");
$errmsg="订单保存失败,原因是您的代理已经提交!";
}
if($msg_dl["is_checked"]=="y" && !$errmsg){
//alert_and_back("订单保存失败,原因是您的代理订单已经确认!");
$errmsg="订单保存失败,原因是您的代理订单已经确认!";
}
}
//判断是否存在规格
$id=$khid;
$is_ggk=is_ggk($id);
//保存订单
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
//判断是否采用服装版本下单
$is_xd_clothes="y";
$msg_size_group=get_db_msg("select title from ".$table_pre."keyword where cate='size' and id='".$msg["size_group"]."'");
if(in_array($msg_size_group["title"],$sys_size_group_xz))
$is_xd_clothes="n";
$json_data.="\"is_xd_clothes\":\"".$is_xd_clothes."\",";
if($sys_ver_hy!="xz"){
if($msg["size_group"]==$bx_sizegroup_id){
//文胸
$arrBx=array();
$r1=$db->query("select * from ".$table_pre."size_bx where no='".$msg["no"]."' order by bx");
$i1=0;
while($m1=$db->fetch_array($r1)){
$arrBx[$i1][]=$m1["bx"];
$arrBx[$i1][]=$m1["size"];
$i1++;
}
//取得尺码
$str_size="";
$r1=$db->query("select * from ".$table_pre."size where iid='".$bx_sizegroup_id."' order by no");
while($m1=$db->fetch_array($r1)){
$str_size.=$m1["no"].",";
}
$str_size=substr($str_size,0,-1);
$arr_size=explode(",",$str_size);
}else if($msg["size_group"]==$child_sizegroup_id){
//童装
$str_size=$str_bx="";
$i1=$j1=0;
foreach($arr_child_bx as $bx1 => $arr_bx_size1){
$check_tmp=get_db_msg("select id,size,price from ".$table_pre."size_bx where no='".$msg["no"]."' and bx='".$bx1."'");
if($check_tmp["id"]>0){
$str_bx.=$i1.",";
$arrBx[$j1][0]=$i1;
$arrBx[$j1][1]=$check_tmp["size"];
$j1++;
}
$i1++;
}
//取得尺码
$str_size="";
$r1=$db->query("select * from ".$table_pre."size where iid='".$child_sizegroup_id."' order by no");
while($m1=$db->fetch_array($r1)){
$str_size.=$m1["no"].",";
}
$str_size=substr($str_size,0,-1);
$arr_size=explode(",",$str_size);
}else{
if($is_ggk!="n"){
$arrBx[0][0]="";
$r1=$db->query("select gg from ".$table_pre."kh_gg where iid='".$msg["id"]."' order by color,ord");
$i1=1;
while($m1=$db->fetch_array($r1)){
$arrBx[$i1][0]=$m1["gg"];
$i1++;
}
}else{
$arrBx[0][0]="";
}
$arrBx[0][1]=$msg["size"];
$arr_size=explode(",",$msg["size"]);
}
//
//print_R($arrBx);
$arr_color=explode(",",$msg["color"]);
$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 uid='".$uid."' and iid='".$id."' and _key='".$_key."'");
//取得总量
for($i=0;$i<count($arr_color);$i++){
//$j=0;
//foreach($arrBx as $tmp_bx => $tmp_size){
for($j=0;$j<count($arrBx);$j++){
/*if($msg["size_group"]==$child_sizegroup_id){
//
}else if($msg["size_group"]==$bx_sizegroup_id){
//
}else{
$tmp_bx=deel_0($tmp_bx);
}*/
$tmp_bx=$arrBx[$j][0];
for($k=0;$k<count($arr_size);$k++){
$v="num_".$arr_color[$i]."_".$tmp_bx."_".$arr_size[$k];
$tmp_total_num+=$$v;
//加入单尺码最大量提示
if($$v>$order_large_num && !$errmsg){
//alert_and_back("对不起,您输入的订量(".$$v.")超过了单尺码最大订量限制(".$order_large_num."),无法保存,请检查!");
$errmsg="对不起,您输入的订量(".$$v.")超过了单尺码最大订量限制(".$order_large_num."),无法保存,请检查!";
}
//echo $v."|".$$v."<br>";
}
//$j++;
}
}
//检查订货规则
$errm="";
for($i=0;$i<count($arr_color);$i++){
if(!in_array($arr_color[$i],$arr_color_ka,true)){
$num1=0;
//$j=0;
//foreach($arrBx as $tmp_bx => $tmp_size){
for($j=0;$j<count($arrBx);$j++){
/*if($msg["size_group"]==$child_sizegroup_id){
//
}else if($msg["size_group"]==$bx_sizegroup_id){
//
}else{
$tmp_bx=deel_0($tmp_bx);
}*/
$tmp_bx=$arrBx[$j][0];
$num_tmp=0;
for($k=0;$k<count($arr_size);$k++){
$v="num_".$arr_color[$i]."_".$tmp_bx."_".$arr_size[$k];
$tmp1=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$arr_size[$k]."'");
$errm.=check_dhgz_dhbs($msg["no"],$tmp_bx,$tmp1["title"],$$v);
$num_tmp+=$$v;
}
$num1+=$num_tmp;
if($is_ggk!="n")
$errm.=check_dhgz_bdgg($msg["no"],$arr_color[$i],$tmp_bx,$num_tmp);
//$j++;
}
$errm.=check_dhgz_bdks($msg,$arr_color[$i],$num1);
$errm.=check_dhgz_qdl($msg,$arr_color[$i],$num1);
}
}
$errm.=check_dhgz_bdk($msg,$tmp_total_num);
$errm.=check_dhgz_qdl($msg,"",$tmp_total_num);
$errm.=check_dhgz_glk($msg["no"],$tmp_total_num);
}else{
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='".$id."'");
//检测配码
$arr_str_sub1=array();
$arr_pm_id=array();
$qy_uid=get_qy_id($msg_login["path"]);
$arr_check_pm=array();
for($i1=0;$i1<count($arr_str_sub);$i1++){
$arr_tmp=explode("|",$arr_str_sub[$i1]);
$arr_gz=explode(":",$arr_tmp[1]);
//echo $arr_tmp[1]."<br>";
$num=count_pm_num($arr_tmp[1]);
$check_pm=$arr_tmp[0].$arr_tmp[1];
if(in_array($check_pm,$arr_check_pm)){
//alert_and_back($arr_tmp[0]."存在相同配码");
$errmsg=$arr_tmp[0]."存在相同配码";
}else{
$arr_check_pm[$i1]=$check_pm;
}
if($num>0){
//取得配码id
$m_pm=get_db_msg("select id from ".$table_pre."size_pm where uid='".$uid."' and khid='".$msg["id"]."' and gz='".$arr_tmp[1]."'");
if($m_pm["id"]>0){
$pmid1=$m_pm["id"];
}else{
//
$tmp=get_db_msg("select title from ".$table_pre."size_pm where gz='".$arr_tmp[1]."' and (uid='".$uid."' or uid='')");
if($tmp["title"])
$pm_title=$tmp["title"];
else
$pm_title="临时".get_rand_num(4);
$q="insert into ".$table_pre."size_pm (qyid,uid,size_group_id,pm_dj,khid,title,gz,num) values ('".$qy_uid."','".$uid."','".$msg["size_group"]."','临时配码','".$msg["id"]."','".$pm_title."','".$arr_tmp[1]."','".$num."')";
//echo $q."<br>";
$db->query($q);
$pmid1=$db->insert_id();
}
$arr_pm_id[$i1]=$pmid1;
}else{
//alert_and_back("请输入尺码!");
$errmsg="请输入尺码!";
}
}
//保存订单
if($is_ggk!="n"){
$arrBx[0][0]="";
$r1=$db->query("select gg from ".$table_pre."kh_gg where iid='".$msg["id"]."' group by gg order by gg");
$i1=1;
while($m1=$db->fetch_array($r1)){
$arrBx[$i1][0]=$m1["gg"];
$i1++;
}
}else{
$arrBx[0][0]="";
}
$arrBx[0][1]=$msg["size"];
//
$arr_size=explode(",",$msg["size"]);
$arr_color=explode(",",$msg["color"]);
$arr_size=explode(",",$msg["size"]);
$arr_color_ka=explode(",",$msg["color_ka"]);
$tmp_total_num=0;
$errm="";
$tmp_old=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where _key='".$sys_this_order_flag."' and uid='".$uid."' and iid='".$id."'");
//取得到色的尺码数量
for($i1=0;$i1<count($arr_str_sub);$i1++){
$arr_tmp=explode("|",$arr_str_sub[$i1]);
$arr_gz=explode(":",$arr_tmp[1]);
$arr_tmp1=explode("_",$arr_tmp[0]);
for($j=0;$j<count($arr_gz);$j++){
$tmp_num=$arr_gz[$j]*$arr_tmp[2];
//到到版型尺码的数量
$v="num_".$arr_tmp1[0]."_".$arr_tmp1[1]."_".$arr_size[$j];
if($is_xd_clothes=="y"){
$$v=$tmp_num;
}else{
$$v+=$tmp_num;
}
//echo $v.":".$$v."<br>";
}
$tmp_num=count_pm_num($arr_tmp[1])*$arr_tmp[2];
//到颜色的数量
$v1="color_num_".$arr_tmp1[0];
$$v1+=$tmp_num;
//到颜色版型的数量
$v2="color_bx_num_".$arr_tmp1[0]."_".$arr_tmp1[1];
$$v2+=$tmp_num;
$tmp_total_num+=$tmp_num;
}
//检查订货规则
for($i=0;$i<count($arr_color);$i++){
if(!in_array($arr_color[$i],$arr_color_ka)){
$num1=0;
for($j=0;$j<count($arrBx);$j++){
$v2="color_bx_num_".$arr_color[$i]."_".$arrBx[$j][0];
if($is_ggk!="n")
$errm.=check_dhgz_bdgg($msg["no"],$arr_color[$i],$arrBx[$j][0],$$v2);
}
$v1="color_num_".$arr_color[$i];
$errm.=check_dhgz_bdks($msg,$arr_color[$i],$$v1);
}
}
$errm.=check_dhgz_bdk($msg,$tmp_total_num);
$errm.=check_dhgz_qdl($msg,"",$tmp_total_num);
$errm.=check_dhgz_glk($msg["no"],$tmp_total_num);
}
if(!$errmsg){
$errmsg=$errm;
}
if($errmsg){
$json_data.="\"code\":0,\"msg\":\"".$errmsg."\",";
}else{
//取得选项
$arr_select_no=array();
$q1="select no from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'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"];
}
if($is_xd_clothes=="y"){
for($i=0;$i<count($arr_color);$i++){
$check1=get_db_msg("select * from ".$table_pre."kh_dp where kh='".$msg["no"]."' and color='".$arr_color[$i]."' and gz='1' limit 0,1");
if(!in_array($arr_color[$i],$arr_color_ka,true) && !$check1["id"]){
//$j=0;
//foreach($arrBx as $tmp_bx => $tmp_size){
for($j=0;$j<count($arrBx);$j++){
/*if($msg["size_group"]==$child_sizegroup_id){
//
}else if($msg["size_group"]==$bx_sizegroup_id){
//
}else{
$tmp_bx=deel_0($tmp_bx);
}*/
$tmp_bx=$arrBx[$j][0];
//echo $tmp_bx."<br>";
$bx_title=($msg["size_group"]==$child_sizegroup_id)?get_child_bx_title($tmp_bx):$tmp_bx;
$sql_size1=$sql_size2=$sql_size3="";
$c=0;
for($k=0;$k<count($arr_size);$k++){
$v="num_".$arr_color[$i]."_".$tmp_bx."_".$arr_size[$k];
//echo $v.":".$$v."<br>";
$c+=$$v;
$sql_size1.="num_".$arr_size[$k]."='".deel_num($$v)."',";
$sql_size2.=",'".deel_num($$v)."'";
$sql_size3.=",num_".$arr_size[$k];
}
$check=get_db_msg("select id from ".$table_pre."order where _key='".$_key."' and uid='".$uid."' and iid='".$id."' and color='".$arr_color[$i]."' and bx='".$bx_title."'");
if($check["id"]){
if($c>0){
$q="update ".$table_pre."order set size_group_id='".$msg["size_group"]."',".$sql_size1."add_date='".time()."' where id='".$check["id"]."'";
//记录订单表sql日志
update_order_log($uid,"update ".$table_pre."order set size_group_id='".$msg["size_group"]."',".$sql_size1."add_date='".time()."' where _key='".$_key."' and uid='".$uid."' and iid='".$id."' and color='".$arr_color[$i]."' and bx='".$bx_title."' and _key='".$_key."'");
$db->query($q);
cache_order($uid,$id,$arr_color[$i],$bx_title);
}else{
$q="delete from ".$table_pre."order where id='".$check["id"]."'";
$db->query($q);
update_order_log($uid,"delete from ".$table_pre."order where _key='".$_key."' and uid='".$uid."' and iid='".$id."' and color='".$arr_color[$i]."' and bx='".$bx_title."' and _key='".$_key."'");
}
}else{
if($c>0){
$sql1=$sql2="";
for($i1=0;$i1<count($arr_select_no);$i1++){
$sql1.=$arr_select_no[$i1].",";
$sql2.="'".$msg[$arr_select_no[$i1]]."',";
}
$gg=$tmp_bx;
$gg_color=$arr_color[$i];
$q="insert into ".$table_pre."order (uid,upath,iid,no,".$sql1."jgd,color,bx,is_sp,size_group_id".$sql_size3.",_key,sx,add_date) values ('".$uid."','".$upath."','".$id."','".$msg["no"]."',".$sql2."'".get_jgd($msg["price"])."','".$arr_color[$i]."','".$bx_title."','".$msg["is_sp"]."','".$msg["size_group"]."'".$sql_size2.",'".$_key."','".get_sx($arr_color[$i])."','".time()."')";
$db->query($q);
update_order_log($uid,"insert into ".$table_pre."order (uid,upath,iid,no,".$sql1."jgd,color,bx,is_sp,size_group_id".$sql_size3.",_key,sx,add_date) values ('".$uid."','".$upath."','".$id."','".$msg["no"]."',".$sql2."'".get_jgd($msg["price"])."','".$arr_color[$i]."','".$bx_title."','".$msg["is_sp"]."','".$msg["size_group"]."'".$sql_size2.",'".$_key."','".get_sx($arr_color[$i])."','".time()."')");
cache_order($uid,$id,$arr_color[$i],$bx_title);
}
}
//$j++;
}
count_ph($uid,$id,$arr_color[$i]);
}
}
}else{
//echo "aaa";
//exit;
for($i=0;$i<count($arr_color);$i++){
$check1=get_db_msg("select * from ".$table_pre."kh_dp where kh='".$msg["no"]."' and color='".$arr_color[$i]."' and gz='1' limit 0,1");
if(!in_array($arr_color[$i],$arr_color_ka) && !$check1["id"]){
for($j=0;$j<count($arrBx);$j++){
$sql_size1=$sql_size2=$sql_size3="";
$c=0;
for($k=0;$k<count($arr_size);$k++){
$v="num_".$arr_color[$i]."_".$arrBx[$j][0]."_".$arr_size[$k];
$c+=$$v;
$sql_size1.="num_".$arr_size[$k]."='".$$v."',";
$sql_size2.=",'".$$v."'";
$sql_size3.=",num_".$arr_size[$k];
}
$check=get_db_msg("select id from ".$table_pre."order where _key='".$sys_this_order_flag."' and uid='".$uid."' and iid='".$id."' and color='".$arr_color[$i]."' and bx='".$arrBx[$j][0]."'");
if($check["id"]){
if($c>0){
$q="update ".$table_pre."order set size_group_id='".$msg["size_group"]."',".$sql_size1."add_date='".time()."' where id='".$check["id"]."'";
$strq.= $q.";";
$db->query($q);
cache_order($uid,$id,$arr_color[$i],$arrBx[$j][0]);
}else{
$q="delete from ".$table_pre."order where id='".$check["id"]."'";
$db->query($q);
}
}else{
if($c>0){
$sql1=$sql2="";
for($i1=0;$i1<count($arr_select_no);$i1++){
$sql1.=$arr_select_no[$i1].",";
$sql2.="'".$msg[$arr_select_no[$i1]]."',";
}
$q="insert into ".$table_pre."order (uid,upath,iid,no,".$sql1."jgd,color,bx,is_sp,size_group_id".$sql_size3.",_key,sx,add_date) values ('".$uid."','".$upath."','".$id."','".$msg["no"]."',".$sql2."'".get_jgd($msg["price"])."','".$arr_color[$i]."','".$arrBx[$j][0]."','".$msg["is_sp"]."','".$msg["size_group"]."'".$sql_size2.",'".$sys_this_order_flag."','".get_sx($arr_color[$i])."','".time()."')";
$strq.= $q.";";
$db->query($q);
cache_order($uid,$id,$arr_color[$i],$arrBx[$j][0]);
}
}
}
count_ph($uid,$id,$arr_color[$i]);
}
}
$json_data.="\"strq\":\"".$strq."\",";
//清空配码信息
$db->query("delete from ".$table_pre."order_pm where _key='".$sys_this_order_flag."' and uid='".$uid."' and iid='".$id."'");
//保存配码信息
for($i1=0;$i1<count($arr_str_sub);$i1++){
$arr_tmp=explode("|",$arr_str_sub[$i1]);
$arr_tmp1=explode("_",$arr_tmp[0]);
$q="insert into ".$table_pre."order_pm (_key,uid,iid,color,bx,pmid,xs) values ('".$sys_this_order_flag."','".$uid."','".$id."','".$arr_tmp1[0]."','".$arr_tmp1[1]."','".$arr_pm_id[$i1]."','".$arr_tmp[2]."')";
$db->query($q);
}
}
//计算数量变化
$log_hd_old_num=$tmp_old["num"];
$log_hd_num=$tmp_total_num-$tmp_old["num"];
//
update_log_hd();
set_order_total($uid);
if($go_url){
$url=$go_url;
}else{
if($auto_back=="y")
$url=$rurl;
else
$url=$_SERVER[PHP_SELF]."?_m=order_single&rurl=".urlencode($rurl)."&id=".$id;
}
$json_data.="\"code\":101,";
}
//echo $url."<br>";
//url_redirect($url);
break;
case "save_pm":
$errmsg=check_pm_gz($pm_gz);
if($errmsg){
$json_data.="\"code\":0,\"msg\":\"".$errmsg."\",";
}else{
$title=trim($pm_title);
$gz=deel_pm_gz($pm_gz);
$qy_uid=get_qy_id($msg_login["path"]);
$num=count_pm_num($gz);
if($khid){
$check=get_db_msg("select * from ".$table_pre."size_pm where uid='".$uid."' and khid='".$khid."' and size_group_id='".$size_group_id."' and title='".$title."'");
}else{
$check=get_db_msg("select * from ".$table_pre."size_pm where uid='".$uid."' and size_group_id='".$size_group_id."' and title='".$title."'");
}
if($check["id"]>0){
if($khid){
$q="update ".$table_pre."size_pm set gz='".$gz."' and khid='".$khid."' where id='".$check["id"]."'";
}else{
$q="update ".$table_pre."size_pm set gz='".$gz."' where id='".$check["id"]."'";
}
}else{
if($khid){
$q="insert into ".$table_pre."size_pm (qyid,uid,khid,size_group_id,title,gz,num) values ('".$qy_uid."','".$uid."','".$khid."','".$size_group_id."','".$title."','".$gz."','".$num."')";
}else{
$q="insert into ".$table_pre."size_pm (qyid,uid,size_group_id,title,gz) values ('".$qy_uid."','".$uid."','".$size_group_id."','".$title."','".$gz."')";
}
}
$db->query($q);
$json_data.="\"code\":101,";
}
//echo "success";
//exit;
break;
case "del_pm":
$title=trim($pm_title);
if($khid){
$q="delete from ".$table_pre."size_pm where uid='".$uid."' and khid='".$khid."' and size_group_id='".$size_group_id."' and title='".$title."'";
}else{
$q="delete from ".$table_pre."size_pm where uid='".$uid."' and size_group_id='".$size_group_id."' and title='".$title."'";
}
$db->query($q);
$json_data.="\"code\":101,";
//echo $q;
//echo "success";
//exit;
break;
case "del":
$errmsg="";
//删除订单
if($order_close=="y"){
//alert_and_back("删除订单失败,原因是系统订单已经关闭!");
$errmsg="删除订单失败,原因是系统订单已经关闭!";
}
if($msg_login["is_checked"]=="y" && !$errmsg){
//alert_and_back("删除订单失败,原因是本用户订单已经确认!");
$errmsg="删除订单失败,原因是本用户订单已经确认!";
}
//判断代理
$dl_uid=get_dl_id($msg_login["path"]);
if($dl_uid>0){
$msg_dl=get_db_msg("select * from ".$table_pre."client where id='".$dl_uid."'");
if($msg_dl["is_jd"]=="y" && !$errmsg){
//alert_and_back("删除订单失败,原因是您的代理已经提交!");
$errmsg="删除订单失败,原因是您的代理已经提交!";
}
if($msg_dl["is_checked"]=="y" && !$errmsg){
//alert_and_back("删除订单失败,原因是您的代理订单已经确认!");
$errmsg="删除订单失败,原因是您的代理订单已经确认!";
}
}
if($errmsg){
$json_data.="\"code\":0,\"msg\":\"".$errmsg."\",";
}else{
$id=$khid;
$tmp_old=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where uid='".$uid."' and iid='".$id."' and ka<>'y' and _key='".$_key."'");
$log_hd_num=$tmp_old["num"];
$q="delete from ".$table_pre."order where iid='".$id."' and uid='".$uid."' and _key='".$_key."' and ka<>'y'";
$db->query($q);
update_order_log($uid,"delete from ".$table_pre."order where iid='".$id."' and uid='".$uid."' and _key='".$_key."' and ka<>'y'");
$m_kh=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
$is_xd_clothes="y";
$msg_size_group=get_db_msg("select title from ".$table_pre."keyword where cate='size' and id='".$m_kh["size_group"]."'");
if(in_array($msg_size_group["title"],$sys_size_group_xz))
$is_xd_clothes="n";
$json_data.="\"is_xd_clothes\":\"".$is_xd_clothes."\",";
if($is_xd_clothes!="y"){
//删除订单配码表
$q="delete from ".$table_pre."order_pm where _key='".$_key."' and iid='".$id."' and uid='".$uid."'";
$db->query($q);
}
//删除搭配款号订单
$m_kh=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
$q1="select zsh from ".$table_pre."kh_dp where kh='".$m_kh["no"]."' and gz<>'' group by zsh";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$q2="select * from ".$table_pre."kh_dp where kh<>'".$m_kh["no"]."' and zsh='".$m1["zsh"]."'";
$r2=$db->query($q2);
while($m2=$db->fetch_array($r2)){
$q3="delete from ".$table_pre."order where no='".$m2["kh"]."' and uid='".$uid."' and color='".$m2["color"]."' and ka<>'y' and _key='".$_key."'";
$tmp_old=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where no='".$m2["kh"]."' and uid='".$uid."' and color='".$m2["color"]."' and ka<>'y' and _key='".$_key."'");
$log_hd_num+=$tmp_old["num"];
$db->query($q3);
update_order_log($uid,"delete from ".$table_pre."order where no='".$m2["kh"]."' and uid='".$uid."' and color='".$m2["color"]."' and ka<>'y' and _key='".$_key."'");
}
}
//
update_log_hd();
set_order_total($uid);
count_ph_uid_kh($uid,$id);
$json_data.="\"code\":101,";
}
/*if($is_window=="n"){
if($go_url){
url_redirect($go_url);
}else{
echo "<script>
if(window.parent)
window.parent.location.href='".$rurl."&auto_dialog=n';
else
window.location.href='".$rurl."&auto_dialog=n';
</script>";
}
}else{
if($go_url){
$url=$go_url;
}else{
if($s_xh>0){
$url=$_SERVER[PHP_SELF]."?_m=order_single&rurl=".urlencode($rurl)."&s_xh=".$s_xh;
}else{
$url=$rurl?$rurl:$_SERVER[PHP_SELF];
}
}
url_redirect($url);
}*/
//echo "<meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\"><script> alert('删除订单成功!'); window.parent.location.reload(); </script>";
break;
default:
//------------------------列表
//---------------搜索条件
$w2=$tmpl_m1_pic_width;
$h2=$tmpl_m1_pic_height;
$page=$page>0?$page:1;
$limit=$limit>0?$limit:12;
$start=($page-1)*$limit;
$end=$limit;
$sql_con="";
$sql_con1="";
if($s_color){
$s_color_a=explode(",",$s_color);
$s1=$s2=$s3="";
//$sql_con_color1="";
for($i1=0;$i1<count($s_color_a);$i1++){
$s1.="color='".$s_color_a[$i1]."' or ";
$s2.="kc.color='".$s_color_a[$i1]."' or ";
//$sql_con_color1.=" b.color<>'".$s_color_a[$i1]."' or ";
}
$sql_con.=" (".substr($s1,0,-3).") and ";
$sql_con1.=" and (".substr($s2,0,-3).")";
//$sql_con_color1=" or (".substr($sql_con_color1,0,-3).")";
$list_by_color="y";
}
//选项
for($i=0;$i<count($arr_select_no);$i++){
$v="s_".$arr_select_no[$i];
if($$v){
$s1=$s2="";
$tmp_a=explode(",",$$v);
for($i1=0;$i1<count($tmp_a);$i1++){
$s1.=$arr_select_no[$i]."='".$tmp_a[$i1]."' or ";
$s2.="a.".$arr_select_no[$i]."='".$tmp_a[$i1]."' or ";
}
$sql_con.=" (".substr($s1,0,-3).") and ";
$sql_con1.=" and (".substr($s2,0,-3).")";
}
}
//到色选项
foreach($sys_color_zd as $k1 => $v1){
$v="s_color_".$k1;
if($$v){
$s1=$s2="";
$tmp_a=explode(",",$$v);
for($i1=0;$i1<count($tmp_a);$i1++){
$s2.="kc.".$k1."='".$tmp_a[$i1]."' or ";
}
$sql_con1.=" and (".substr($s2,0,-3).")";
$list_by_color="y";
}
}
if($s_ka=="y"){
$sql_con.=" (ka='y' or color_ka<>'') and ";
$sql_con1.=" and (a.ka='y')";
}else{
$sql_con.=" (ka<>'y') and ";
$sql_con1.=" and (a.ka<>'y')";
}
/*if($s_con=="no" && $s_value_no!=""){
$sql_con.=$s_con." like '%".$s_value_no."%' and ";
$sql_con1.=" and a.".$s_con." like '%".$s_value_no."%'";
}*/
if($sql_con)
$sql_con=" where ".substr($sql_con,0,-4);
$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=" where no='".$tmp["no"]."'";
$sql_con1=" and a.no like '%".$tmp["no"]."%'";
for($i=0;$i<count($arr_select_no);$i++){
$v="s_".$arr_select_no[$i];
$$v="";
}
$s_xj="";
$s_is_ordered="";
$offset=0;
}
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=" where (no='".$tmp["no"]."' or no like '%".$s_keyword."%')";
$sql_con1=" and (a.no='".$tmp["no"]."' or a.no like '%".$s_keyword."%')";
}else{
$sql_con=" where no like '%".$s_keyword."%'";
$sql_con1=" and a.no like '%".$s_keyword."%'";
}
for($i=0;$i<count($arr_select_no);$i++){
$v="s_".$arr_select_no[$i];
$$v="";
}
$s_xj="";
$s_is_ordered="";
$offset=0;
}
/*if($s_con=="xh" && $s_value_xh!=""){
$sql_con="where xh='".$s_value_xh."'";
for($i=0;$i<count($arr_select_no);$i++){
$v="s_".$arr_select_no[$i];
$$v="";
}
$s_xj="";
$s_is_ordered="";
$offset=0;
}*/
//评价星级的条件定制
$con_pjxj="";
if($s_xj){
if(strpos($s_xj,"y")!==false){
//已评
$con_pjxj=" and c.race>0 ";
}else if(strpos($s_xj,"n")!==false){
//未评
$con_pjxj=" and c.race is NULL ";
}else{
$arr_tmp=explode(",",$s_xj);
for($i1=0;$i1<count($arr_tmp);$i1++){
$con_pjxj.=" c.race='".$arr_tmp[$i1]."' or ";
}
$con_pjxj=" and (".substr($con_pjxj,0,-3).") ";
}
}
//$sql_order=str_replace("!"," desc",$order);
$sql_size1="";
for($s1=1;$s1<=$sys_size_num;$s1++){
$sql_size1.="b.num_".$s1."+";
}
if($sql_size1)
$sql_size1=substr($sql_size1,0,-1);
if($list_by_color=="y"){
//展示到色
if($s_is_ordered=="y"){
if($s_xj){
$query="select count(distinct kc.iid,kc.color) 'total' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on a.id=kc.iid left join ".$table_pre."order o on kc.iid=o.iid and kc.color=o.color and o.uid='".$uid."' left join ".$table_pre."client_pj c on o.iid=c.khid and c.cid='".$uid."' where o.num>0 and o._key='".$_key."' ".$con_pjxj.$sql_con1;
//echo $query."<br>";
}else{
$query="select count(distinct kc.iid,kc.color) 'total' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on a.id=kc.iid left join ".$table_pre."order o on kc.iid=o.iid and kc.color=o.color and o.uid='".$uid."' where o.num>0 and o._key='".$_key."' ".$sql_con1;
}
}else if($s_is_ordered=="n"){
if($s_xj){
$query="select count(distinct kc.iid,kc.color) 'total' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on a.id=kc.iid left join ".$table_pre."order o on kc.iid=o.iid and kc.color=o.color and o.uid='".$uid."' and o._key='".$_key."' left join ".$table_pre."client_pj c on o.iid=c.khid and c.cid='".$uid."' where o.num is NULL ".$con_pjxj.$sql_con1;
}else{
$query="select count(distinct kc.iid,kc.color) 'total' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on a.id=kc.iid left join ".$table_pre."order o on kc.iid=o.iid and kc.color=o.color and o.uid='".$uid."' and o._key='".$_key."' where o.num is NULL ".$sql_con1;
}
}else{
if($s_xj){
$query="select count(distinct kc.iid,kc.color) 'total' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on a.id=kc.iid left join ".$table_pre."client_pj c on kc.iid=c.khid and c.cid='".$uid."' where kc.id>0".$con_pjxj.$sql_con1;
}else{
$query="select count(distinct kc.iid,kc.color) 'total' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on a.id=kc.iid where kc.id>0".$sql_con1;
}
}
}else{
//展示到款
if($s_is_ordered=="y"){
if($s_xj){
$query="select count(distinct c.khid) 'total' from ".$table_pre."order a left join ".$table_pre."client_pj c on a.iid=c.khid and c.cid='".$uid."' where a.uid='".$uid."' and a._key='".$_key."' ".$con_pjxj.$sql_con1;
}else{
$query="select count(distinct a.iid) 'total' from ".$table_pre."order a where a.uid='".$uid."' and a._key='".$_key."' ".$sql_con1;
}
}else if($s_is_ordered=="n"){
if($s_xj){
$query="select count(*) 'total' from ".$table_pre."kh a left join ".$table_pre."order b on a.id=b.iid and b.uid='".$uid."' left join ".$table_pre."client_pj c on a.id=c.khid and c.cid='".$uid."' and b._key='".$_key."' where b.num is NULL ".$con_pjxj.$sql_con1;
}else{
$query="select count(*) 'total' from ".$table_pre."kh a left join ".$table_pre."order b on a.id=b.iid and b.uid='".$uid."' and b._key='".$_key."' where b.num is NULL ".$sql_con1;
}
}else{
if($s_xj){
$query="select count(*) 'total' from ".$table_pre."kh a left join ".$table_pre."client_pj c on a.id=c.khid and c.cid='".$uid."' where a.id>0 ".$con_pjxj.$sql_con1;
}else{
$query="select count(*) 'total' from ".$table_pre."kh ".$sql_con;
}
}
}
//echo $query."<br>";
//$json_data.="\"query\":\"".$query."\",";
$res=$db->query($query);
$msg=$db->fetch_array($res);
$total_num=$msg["total"];
if($list_by_color=="y"){
//------------------展示到色
//定制条件
if($s_is_ordered=="y"){
if($s_xj){
$query="select a.*,c.race,b.num,kc.color 'color' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on kc.iid=a.id left join ".$table_pre."order b on kc.iid=b.iid and b.uid='".$uid."' left join ".$table_pre."client_pj c on kc.iid=c.khid and c.cid='".$uid."' where b.num>0 and b._key='".$_key."' ".$con_pjxj.$sql_con1." group by kc.id,kc.color order by a.xh,a.no limit ".$start.",".$end;
}else{
$query="select a.*,b.num,kc.color 'color' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on kc.iid=a.id left join ".$table_pre."order b on kc.iid=b.iid and kc.color=b.color and b.uid='".$uid."' where b.num>0 and b._key='".$_key."' ".$sql_con1." group by kc.id,kc.color order by a.xh,a.no limit ".$start.",".$end;
}
//echo $query."<br>";
}else if($s_is_ordered=="n"){
if($s_xj){
$query="select a.*,c.race,b.num,kc.color 'color' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on kc.iid=a.id left join ".$table_pre."order b on kc.iid=b.iid and b.color=kc.color and b.uid='".$uid."' left join ".$table_pre."client_pj c on kc.iid=c.khid and c.cid='".$uid."' and b._key='".$_key."' where b.num is NULL ".$con_pjxj.$sql_con1." group by kc.id,kc.color order by a.xh,a.no limit ".$start.",".$end;
}else{
$query="select a.*,b.num,kc.color 'color' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on kc.iid=a.id left join ".$table_pre."order b on kc.iid=b.iid and b.color=kc.color and b.uid='".$uid."' and b._key='".$_key."' where b.num is NULL ".$sql_con1." group by kc.id,kc.color order by a.xh,a.no limit ".$start.",".$end;
}
}else{
if($s_xj){
$query="select a.*,c.race,kc.color 'color' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on kc.iid=a.id left join ".$table_pre."client_pj c on kc.iid=c.khid and c.cid='".$uid."' where kc.id>0".$con_pjxj.$sql_con1." group by kc.id,kc.color order by a.xh,a.no limit ".$start.",".$end;
}else{
$query="select a.*,kc.color 'color' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on kc.iid=a.id where kc.id>0".$sql_con1." group by kc.id,kc.color order by a.xh,a.no limit ".$start.",".$end;
}
}
if($xh_ms=="2"){
//-------定制序号查询
if($s_con=="xh" && $s_value_xh!=""){
$query="select a.*,b.xh 'xh' from ".$table_pre."kh a,".$table_pre."kh_xh b where a.no=b.kh and b.xh='".$s_value_xh."'";
}
}
//echo $query."<br>";
//$json_data.="\"query\":\"".$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.="\"s_keyword\":\"".$s_keyword."\",";
$json_data.="\"ka_color\":\"".$ka_color."\",";
$json_data.="\"content_set\":\"".$pic_background."\",";
$json_data.="\"list_by_color\":\"".$list_by_color."\",";
$json_data.="\"count\":".$total_num.",\"data\":[";
$data_str="";
$content_list="[";
$arr_id=array();
for($count=0;$count<$end;$count++){
$msg=$db->fetch_array($res);
$arr_id[$count]=$msg["id"];
if($msg["ka"]=="y"){
$c=get_set("ka_color");
}else{
$c=get_set_value_dote($style_title_color,$msg["kh_dj"]);
}
if($msg["id"]>0){
//图片获取规则
$pic=get_kh_color_picture($msg["no"],$msg["color"],$flag_pad_offline);
//取得已订件数
$n1=deel_num(get_order_num_kh_color($msg["id"],$msg["color"]));
//取得颜色数量
$str_c_num=",".$msg["color"]."-".get_cate_title_no("color",$msg["color"]);
//取得上次订货会数量
$str_sys="";
if($sys_flag_count>1){
$tmp_sys=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where _key<>'".$_key."' and iid='".$msg["id"]."' and color='".$msg["color"]."' and uid='".$uid."'");
if($tmp_sys["num"]){
$str_sys="\"scjs\":".$tmp_sys["num"].",\"hjjs\":".($tmp_sys["num"]+$n1).",";
}
$str_sys.="\"lssj\":\"y\",";
}
//取得评价信息
$tmp=get_db_msg("select id,race,remark from ".$table_pre."client_pj where khid='".$msg["id"]."' and cid='".$uid."'");
$pj_race=$tmp["race"]>0?$tmp["race"]:0;
$pj_id=$tmp["id"]>0?$tmp["id"]:0;
$pj_remark=deel_js_var($tmp["remark"]);
$msg_pj=$pj_id."|".$pj_race."|".deel_js_var($tmp["remark"]);
//取得滑动展示信息
$text_main="";
$q="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'jgd' and no<>'sx' and no<>'color' order by ord";
$r=$db->query($q);
$tmpzd="";
while($m=$db->fetch_array($r)){
if($m["no"]=="zd1" || $m["no"]=="zd2" || $m["no"]=="zd3"){
$tmpzd.=",\"".$m["no"]."\":\"".$msg[$m["no"]]."\"";
$text_main.=$msg[$m["no"]]."";
}else{
$tmpzd.=",\"".$m["no"]."\":\"".deel_js_var(get_cate_title_no($m["no"],$msg[$m["no"]]))."\"";
$text_main.=deel_js_var(get_cate_title_no($m["no"],$msg[$m["no"]]))."";
}
}
if($text_main)
$text_main=substr($text_main,0,-2);
if($msg["remark"]!="")
$text_main.="<br>".deel_js_var(dhtmlchars($msg["remark"]));
if($msg["size_group"]==$child_sizegroup_id){
//童装不显示价格
$this_price=0;
}else{
$this_price=deel_num(get_price_dp($uid,$msg["id"]));
}
//$content_list.="".$msg["id"].",\"".get_kh_xh($msg,$msg["color"])."\",\"".$msg["no"].$str_c_num."\",".$this_price.",\"".$pic."\",\"".str_replace("\"","'",out_good_pic_set($pic,$w2,$h2))."\",".$n1.",\"".$c."\",\"".$msg_pj."\",\"".$text_main."\",";
//
$rnum++;
$ck=out_good_pic_set_arr($pic,$w2,$h2);
$data_str.="{\"id\":".$msg["id"].",\"xh\":\"".get_kh_xh($msg,$msg["color"])."\",\"kh\":\"".$msg["no"]."\",\"color\":\"".$msg["color"]."\",\"color_title\":\"".get_cate_title_no("color",$msg["color"])."\",\"pic\":\"".$pic."\",\"pic_w\":".$ck[0].",\"pic_h\":".$ck[1].",\"ydjs\":".$n1.",\"unit_title\":\"".$msg["unit_title"]."\",".$str_sys."\"price\":".$this_price.",\"xj\":\"".$pj_race."\",\"pj_remark\":\"".$pj_remark."\"".$tmpzd."},";
}
}
$content_list.="]";
}else{
//------------------展示到款
//定制条件
if($s_is_ordered=="y"){
if($s_xj){
$query="select a.*,c.race,b.num from ".$table_pre."kh a left join ".$table_pre."order b on a.id=b.iid and b.uid='".$uid."' left join ".$table_pre."client_pj c on a.id=c.khid and c.cid='".$uid."' where b.num>0 and b._key='".$_key."' ".$con_pjxj.$sql_con1." group by a.id order by a.xh,a.no limit ".$start.",".$end;
}else{
$query="select a.*,b.num from ".$table_pre."kh a left join ".$table_pre."order b on a.id=b.iid and b.uid='".$uid."' where b.num>0 and b._key='".$_key."' ".$sql_con1." group by a.id order by a.xh,a.no limit ".$start.",".$end;
}
//echo $query."<br>";
}else if($s_is_ordered=="n"){
if($s_xj){
$query="select a.*,c.race,b.num from ".$table_pre."kh a left join ".$table_pre."order b on a.id=b.iid and b.uid='".$uid."' left join ".$table_pre."client_pj c on a.id=c.khid and c.cid='".$uid."' and b._key='".$_key."' where b.num is NULL ".$con_pjxj.$sql_con1." order by a.xh,a.no limit ".$start.",".$end;
}else{
$query="select a.*,b.num from ".$table_pre."kh a left join ".$table_pre."order b on a.id=b.iid and b.uid='".$uid."' and b._key='".$_key."' where (b.num is NULL) ".$sql_con1." order by a.xh,a.no limit ".$start.",".$end;
}
}else{
if($s_xj){
$query="select a.*,c.race from ".$table_pre."kh a left join ".$table_pre."client_pj c on a.id=c.khid and c.cid='".$uid."' where a.id>0 ".$con_pjxj.$sql_con1." order by a.xh,a.no limit ".$start.",".$end;
}else{
$query="select * from ".$table_pre."kh ".$sql_con."order by xh,no limit ".$start.",".$end;
}
}
if($xh_ms=="2"){
//-------定制序号查询
if($s_con=="xh" && $s_value_xh!=""){
$query="select a.*,b.xh 'xh' from ".$table_pre."kh a,".$table_pre."kh_xh b where a.no=b.kh and b.xh='".$s_value_xh."'";
}
}
//echo $query."<br>";
$json_data.="\"query\":\"".$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.="\"list_by_color\":\"".$list_by_color."\",";
$json_data.="\"count\":".$total_num.",\"data\":[";
$data_str="";
$content_list="[";
$arr_id=array();
for($count=0;$count<$end;$count++){
$msg=$db->fetch_array($res);
$arr_id[$count]=$msg["id"];
if($msg["ka"]=="y"){
$c=get_set("ka_color");
}else{
$c=get_set_value_dote($style_title_color,$msg["kh_dj"]);
}
if($msg["id"]>0){
//图片获取规则
$pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"],$flag_pad_offline);
//取得已订件数
$n1=deel_num(get_order_num_kh($msg["id"]));
//取得颜色数量
$c_num=count(explode(",",$msg["color"]));
$str_c_num="";
if($is_dkds!="y"){
$str_c_num=" (".$c_num."色)";
}
//取得上次订货会数量
$str_sys="";
if($sys_flag_count>1){
$tmp_sys=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where _key<>'".$_key."' and iid='".$msg["id"]."' and uid='".$uid."'");
if($tmp_sys["num"]){
$str_sys="\"scjs\":".$tmp_sys["num"].",\"hjjs\":".($tmp_sys["num"]+$n1).",";
}
$str_sys.="\"lssj\":\"y\",";
}
//取得评价信息
$tmp=get_db_msg("select id,race,remark from ".$table_pre."client_pj where khid='".$msg["id"]."' and cid='".$uid."'");
$pj_race=$tmp["race"]>0?$tmp["race"]:0;
$pj_id=$tmp["id"]>0?$tmp["id"]:0;
$pj_remark=deel_js_var($tmp["remark"]);
$msg_pj=$pj_id."|".$pj_race."|".deel_js_var($tmp["remark"]);
//取得滑动展示信息
$text_main="";
$q="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'jgd' and no<>'sx' and no<>'color' order by ord";
$r=$db->query($q);
$tmpzd="";
while($m=$db->fetch_array($r)){
if($m["no"]=="zd1" || $m["no"]=="zd2" || $m["no"]=="zd3"){
$tmpzd.=",\"".$m["no"]."\":\"".$msg[$m["no"]]."\"";
$text_main.=$msg[$m["no"]]."";
}else{
$tmpzd.=",\"".$m["no"]."\":\"".deel_js_var(get_cate_title_no($m["no"],$msg[$m["no"]]))."\"";
$text_main.=deel_js_var(get_cate_title_no($m["no"],$msg[$m["no"]]))."";
}
}
if($text_main)
$text_main=substr($text_main,0,-2);
if($msg["remark"]!="")
$text_main.="<br>".deel_js_var(dhtmlchars($msg["remark"]));
//$content_list.="".$msg["id"].",\"".get_kh_xh($msg)."\",\"".$msg["no"].$str_c_num."\",".deel_num(get_price_dp($uid,$msg["id"])).",\"".$pic."\",\"".str_replace("\"","'",out_good_pic_set($pic,$w2,$h2))."\",".$n1.",\"".$c."\",\"".$msg_pj."\",\"".$text_main."\",";
//
$rnum++;
$ck=out_good_pic_set_arr($pic,$w2,$h2);
$data_str.="{\"id\":".$msg["id"].",\"xh\":\"".get_kh_xh($msg)."\",\"kh\":\"".$msg["no"]."\",\"pic\":\"".$pic."\",\"color\":\"nocolor\",\"color_title\":\"\",\"pic_w\":".$ck[0].",\"pic_h\":".$ck[1].",\"ydjs\":".$n1.",\"unit_title\":\"".$msg["unit_title"]."\",".$str_sys."\"ka_color\":\"".$c."\",\"price\":".deel_num(get_price_dp($uid,$msg["id"])).",\"xj\":\"".$pj_race."\",\"pj_remark\":\"".$pj_remark."\"".$tmpzd."},";
}
}
$content_list.="]";
}
$json_data.=substr($data_str,0,-1)."],";
//---------------款号数据
//传递参数:s_brand|选项,s_xj|星级,s_is_order|已订,s_is_ka|删除款
//每次加载条数
$page_size=12;
//图片标准188*250
/*$json_data.="\"data\":[";
$json_data.="{\"id\":1,\"xh\":\"1\",\"kh\":\"12W1102\",\"pic\":\"../attachments/design/mini/12W1102.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":4,\"price\":587,\"xj\":4,\"khdj\":\"必订\"},";
$json_data.="{\"id\":2,\"xh\":\"2\",\"kh\":\"12W010251\",\"pic\":\"../attachments/design/mini/12W0102_51.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":897,\"xj\":5,\"khdj\":\"常规\"},";
$json_data.="{\"id\":3,\"xh\":\"3\",\"kh\":\"12W1123\",\"pic\":\"../attachments/design/mini/12W1123_91.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":2,\"price\":865,\"xj\":0,\"khdj\":\"常规\"},";
$json_data.="{\"id\":4,\"xh\":\"4\",\"kh\":\"12W3110\",\"pic\":\"../attachments/design/mini/12W3110_91.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":110,\"price\":759,\"xj\":2,\"khdj\":\"推荐\"},";
$json_data.="{\"id\":5,\"xh\":\"5\",\"kh\":\"12W3128\",\"pic\":\"../attachments/design/mini/12W3128_41.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":1200,\"xj\":1,\"khdj\":\"常规\"},";
$json_data.="{\"id\":6,\"xh\":\"6\",\"kh\":\"12W3127\",\"pic\":\"../attachments/design/mini/12W3127_91.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":600,\"xj\":5,\"khdj\":\"常规\"},";
$json_data.="{\"id\":7,\"xh\":\"7\",\"kh\":\"12W3105\",\"pic\":\"../attachments/design/mini/12W3105_91.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":800,\"xj\":0,\"khdj\":\"\"},";
$json_data.="{\"id\":8,\"xh\":\"8\",\"kh\":\"12W2112\",\"pic\":\"../attachments/design/mini/12W2112_41.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":800,\"xj\":0,\"khdj\":\"\"},";
$json_data.="{\"id\":9,\"xh\":\"9\",\"kh\":\"12W2123\",\"pic\":\"../attachments/design/mini/12W2123_82.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":800,\"xj\":0,\"khdj\":\"\"},";
$json_data.="{\"id\":10,\"xh\":\"10\",\"kh\":\"12W3106\",\"pic\":\"../attachments/design/mini/12W3106_52.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":800,\"xj\":0,\"khdj\":\"\"},";
$json_data.="{\"id\":11,\"xh\":\"11\",\"kh\":\"12W5104\",\"pic\":\"../attachments/design/mini/12W5104_11.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":800,\"xj\":0,\"khdj\":\"\"},";
$json_data.="{\"id\":12,\"xh\":\"12\",\"kh\":\"12W5117\",\"pic\":\"../attachments/design/mini/12W5117_11.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":800,\"xj\":0,\"khdj\":\"\"}";
$json_data.="],";*/
//总计条数
$json_data.="\"total_num\":".$total_num.",";
//已经加载条数
//$json_data.="\"show_num\":12,";
$total_page=ceil($total_num/$limit);
$json_data.="\"total_page\":".$total_page.",";
$json_data.="\"page\":".$page.",";
//已经加载条数
//$json_data.="\"show_num\":12,";
//单独下拉字段
$select_dz="";
$arrdd=array();
for($i=0;$i<count($sys_dk_search_cate_single);$i++){
//取得选项
$tmp="";
$r1=$db->query("select no,title from ".$table_pre."keyword where cate='".$sys_dk_search_cate_single[$i]."' order by no");
while($m1=$db->fetch_array($r1)){
$tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
}
$tmp=deel_end($tmp);
$var="s_".$sys_dk_search_cate_single[$i];
$arrdd[]=$var;
$select_dz.="{\"no\":\"".$sys_dk_search_cate_single[$i]."\",\"title\":\"".get_cate_title_no("arr_select",$sys_dk_search_cate_single[$i])."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
$select_dz=deel_end($select_dz);
$json_data.="\"select_single\":[".$select_dz."],";
//更多条件下拉字段
$select_dz="";
for($i=0;$i<count($sys_dk_search_cate);$i++){
$var="s_".$sys_dk_search_cate[$i];
if(!in_array($var,$arrdd)){
if($sys_dk_search_cate[$i]=="color"){
$tmp="";
$r1=$db->query("select no,title from ".$table_pre."keyword where cate='".$sys_dk_search_cate[$i]."' order by no");
while($m1=$db->fetch_array($r1)){
$tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
}
$tmp=deel_end($tmp);
$select_dz.="{\"no\":\"".$sys_dk_search_cate[$i]."\",\"title\":\"颜色\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}elseif(substr($sys_dk_search_cate[$i],0,6)=="color_"){
$tmp_key=str_replace("color_","",$sys_dk_search_cate[$i]);
$tmp="";
$r1=$db->query("select no,title from ".$table_pre."keyword where cate='".$tmp_key."' order by no");
while($m1=$db->fetch_array($r1)){
$tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
}
$tmp=deel_end($tmp);
$select_dz.="{\"no\":\"".$sys_dk_search_cate[$i]."\",\"title\":\"".get_main_value($sys_color_zd,$tmp_key)."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}else{
$tmp="";
$r1=$db->query("select no,title from ".$table_pre."keyword where cate='".$sys_dk_search_cate[$i]."' order by no");
while($m1=$db->fetch_array($r1)){
$tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
}
$tmp=deel_end($tmp);
$select_dz.="{\"no\":\"".$sys_dk_search_cate[$i]."\",\"title\":\"".get_cate_title_no("arr_select",$sys_dk_search_cate[$i])."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
}
}
//$json_data.="\"select_more\":[";
//
//$json_data.="{\"no\":\"category\",\"title\":\"大类\",\"value\":\"1,2\",\"op\":[{\"no\":\"1\",\"title\":\"上装\"},{\"no\":\"2\",\"title\":\"下装\"},{\"no\":\"3\",\"title\":\"饰品\"}]},";
//$json_data.="{\"no\":\"bc\",\"title\":\"波段\",\"value\":\"11\",\"op\":[{\"no\":\"11\",\"title\":\"第一波\"},{\"no\":\"12\",\"title\":\"第二波\"}]},";
//星级筛选
$select_dz.="{\"no\":\"xj\",\"title\":\"星级\",\"value\":\"".$s_xj."\",\"op\":[{\"no\":\"1\",\"title\":\"1星\"},{\"no\":\"2\",\"title\":\"2星\"},{\"no\":\"3\",\"title\":\"3星\"},{\"no\":\"4\",\"title\":\"4星\"},{\"no\":\"5\",\"title\":\"5星\"},{\"no\":\"y\",\"title\":\"已评\"},{\"no\":\"n\",\"title\":\"未评\"}]},";
//已订,未订
$select_dz.="{\"no\":\"is_ordered\",\"title\":\"已订未订\",\"value\":\"".$s_is_ordered."\",\"op\":[{\"no\":\"y\",\"title\":\"已订\"},{\"no\":\"n\",\"title\":\"未订\"}]},";
//是否删除款
$select_dz.="{\"no\":\"ka\",\"title\":\"是否删除款\",\"value\":\"".$s_ka."\",\"op\":[{\"no\":\"n\",\"title\":\"非删除款\"},{\"no\":\"y\",\"title\":\"仅删除款\"}]},";
//
$select_dz=deel_end($select_dz);
$json_data.="\"select_more\":[".$select_dz."],";
$json_data.="\"s_keyword\":\"".$s_keyword."\",";
$json_data.="\"last_path\":\"".$last_path."\",";
break;
}
}else if($msg_login["face"]=="2"){
$key_bhdp="备货";
$partten="/".$key_bhdp."/i";
$arr_upath=explode(",",$msg_login["charge_path"]);
switch($_a){
case "get_wcl":
//获取完成率和已订件数,传递参数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 ka<>'y' and _key='".$_key."'");
$tmp=get_db_msg("select sum(num) 'num' from ".$table_pre."order where ka<>'y' and _key='".$_key."' and iid='".$khid."' ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"")."");
$k_ydjs=$tmp["num"];
//取得上次订货会数量
$str_sys="";
if($sys_flag_count>1){
$tmp_sys=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where _key<>'".$_key."' and iid='".$khid."' ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"")."");
$tmp_kh=get_db_msg("select * from ".$table_pre."kh where id='".$khid."'");
if($tmp_sys["num"]){
$str_sys="\"scjs\":".$tmp_sys["num"].",\"hjjs\":".($tmp_sys["num"]+$n1).",";
}
$str_sys.="\"lssj\":\"y\",\"unit_title\":\"".$tmp_kh["unit_title"]."\",";
}
}else{
$k_ydjs=0;
}
//该款已订件数
//$zb_client_show=get_set("zb_client_show");
$json_data.="\"ydjs\":\"".$k_ydjs."\",".$str_sys;
//$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."\",";
break;
case "save":
$errmsg="";
$id=$khid;
//保存订单
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
$is_xd_clothes="y";
$msg_size_group=get_db_msg("select title from ".$table_pre."keyword where cate='size' and id='".$msg["size_group"]."'");
if(in_array($msg_size_group["title"],$sys_size_group_xz))
$is_xd_clothes="n";
$arr_color=explode(",",$msg["color"]);
$arr_color_ka=explode(",",$msg["color_ka"]);
if($order_close=="y"){
//alert_and_back("订单保存失败,原因是系统订单已经关闭!");
$errmsg="订单保存失败,原因是系统订单已经关闭!";
}
if($errmsg){
$json_data.="\"code\":0,\"msg\":\"".$errmsg."\",";
}else{
$msg_client="";
if($msg["size_group"]==$bx_sizegroup_id){
$tmp=get_db_msg("select * from ".$table_pre."size_bx where no='".$msg["no"]."' and bx='".$bx."'");
$arr_size=explode(",",$tmp["size"]);
}else{
$arr_size=explode(",",$msg["size"]);
}
//取得选项
$arr_select_no=array();
$q1="select no from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'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"];
}
if($sys_ver_hy!="xz"){
//取得店铺等级
$arr_dpdj=array();
$arr_dpdj_dp=array();
$arr_all_dp=array();
$tmpdpdj="{\"dj\":\"_ALL_\",\"title\":\"所有店铺\"},";
$j=0;
for($i=0;$i<count($arr_upath);$i++){
$tmp_uid=get_parent_id($arr_upath[$i]);
$tmp=get_db_msg("select dj,face from ".$table_pre."client where id='".$tmp_uid."'");
if($tmp["face"]=="4"){
$arr_dpdj_dp[$tmp["dj"]][]=$tmp_uid;
if($tmp["dj"]!="" && !in_array($tmp["dj"],$arr_dpdj)){
$arr_dpdj[$tmp["dj"]]=$tmp["dj"];
$tmpdpdj.="{\"dj\":\"".$tmp["dj"]."\",\"title\":\"".$tmp["dj"]."\"},";
if($s_dpdj=="" && $j==0)
$s_dpdj=$tmp["dj"];
$j++;
}
$arr_all_dp[]=$tmp_uid;
}
}
$tmpdpdj=deel_end($tmpdpdj);
//$json_data.="\"s_dpdj\":[".$tmpdpdj."],";
//取得店铺
$arr_dp=array();
foreach($arr_dpdj_dp as $dj1 => $arr_dp1){
if($s_dpdj=="_ALL_"){
$arr_dp=$arr_all_dp;
}else{
if($dj1==$s_dpdj){
$arr_dp=$arr_dp1;
}
}
}
for($i=0;$i<count($arr_dp);$i++){
$tmp_uid=$arr_dp[$i];
$q="select * from ".$table_pre."client where id='".$tmp_uid."'";
//echo $q."<Br>";
$m=get_db_msg($q);
if($m["face"]=="4"){
//
$is_save="y";
if($msg_login["qyjl_order"]=="b" && !preg_match($partten,$m["title"]))
$is_save="n";
if($is_brand=="y"){
//启用多品牌
$check1=get_db_msg("select id,is_jd,is_checked from ".$table_pre."client_brand where cid='".$m["id"]."' and brand='".$msg["brand"]."'");
if($check1["is_jd"]=="y"){
$is_save="n";
}
if($check1["is_checked"]=="y"){
$is_save="n";
}
if($check1["id"]>0){
//有权限
}else{
$is_save="n";
}
}else{
if($m["is_jd"]=="y"){
$is_save="n";
}
if($m["is_checked"]=="y"){
$is_save="n";
}
}
if($is_save=="y"){
//
$sql_size1=$sql_size2=$sql_size3="";
$c=0;
$flag="n";
for($k=0;$k<count($arr_size);$k++){
$v="num_".$m["id"]."_".$bx."_".$arr_size[$k];
$c+=$$v;
$sql_size1.="num_".$arr_size[$k]."='".deel_num($$v)."',";
$sql_size2.=",'".deel_num($$v)."'";
$sql_size3.=",num_".$arr_size[$k];
if($$v>$order_large_num && !$errmsg){
$flag="y";
$msg_client.=$m["title"]."的订量(".$$v.")超过了单尺码最大订量限制(".$order_large_num."),无法保存,请检查!|";
}
}
$client_dj=trim($m["dj"]);
$con_dj=$client_dj?" and (dj='".$client_dj."' or dj='')":" and dj=''";
$qdl=get_db_msg("select num from ".$table_pre."gz where cate='qdl' and kh='".$msg["no"]."' and color='".$color."'".$con_dj);
if($c<$qdl["num"] && $c) {
//alert_and_back($m["title"]."单店订量必须大于起订量:".$qdl["num"]."件!");
$msg_client.=$m["title"]."单店订量必须大于起订量:".$qdl["num"]."件!|";
$flag="y";
}
if($flag=="n"){
$check=get_db_msg("select * from ".$table_pre."order where uid='".$tmp_uid."' and iid='".$msg["id"]."' and color='".$color."' and bx='".$bx."' and _key='".$_key."'");
if($check["id"]){
if($c>0){
$q="update ".$table_pre."order set size_group_id='".$msg["size_group"]."',".$sql_size1."add_date='".time()."' where id='".$check["id"]."'";
$json_data.="\"q\":\"".$q."\",";
$db->query($q);
update_order_log($tmp_uid,"update ".$table_pre."order set size_group_id='".$msg["size_group"]."',".$sql_size1."add_date='".time()."' where uid='".$tmp_uid."' and iid='".$msg["id"]."' and color='".$color."' and bx='".$bx."' and _key='".$_key."'");
cache_order($m["id"],$msg["id"],$color,$bx);
}else{
$q="delete from ".$table_pre."order where id='".$check["id"]."'";
$json_data.="\"q\":\"".$q."\",";
$db->query($q);
update_order_log($tmp_uid,"delete from ".$table_pre."order where uid='".$tmp_uid."' and iid='".$msg["id"]."' and color='".$color."' and bx='".$bx."' and _key='".$_key."'");
}
}else{
if($c>0){
//取得选项
$sql1=$sql2="";
for($i1=0;$i1<count($arr_select_no);$i1++){
$sql1.=$arr_select_no[$i1].",";
$sql2.="'".$msg[$arr_select_no[$i1]]."',";
}
$q="insert into ".$table_pre."order (uid,upath,iid,no,".$sql1."jgd,color,bx,is_sp,size_group_id".$sql_size3.",_key,sx,add_date) values ('".$m["id"]."','".($m["path"]."-".$m["id"])."','".$msg["id"]."','".$msg["no"]."',".$sql2."'".get_jgd($msg["price"])."','".$color."','".$bx."','".$msg["is_sp"]."','".$msg["size_group"]."'".$sql_size2.",'".$_key."','".get_sx($color)."','".time()."')";
$json_data.="\"q\":\"".$q."\",";
$db->query($q);
update_order_log($m["id"],"insert into ".$table_pre."order (uid,upath,iid,no,".$sql1."jgd,color,bx,is_sp,size_group_id".$sql_size3.",_key,sx,add_date) values ('".$m["id"]."','".($m["path"]."-".$m["id"])."','".$msg["id"]."','".$msg["no"]."',".$sql2."'".get_jgd($msg["price"])."','".$color."','".$bx."','".$msg["is_sp"]."','".$msg["size_group"]."'".$sql_size2.",'".$_key."','".get_sx($color)."','".time()."')");
cache_order($m["id"],$msg["id"],$color,$bx);
}
}
set_order_total($m["id"]);
count_ph($m["id"],$msg["id"],$color);
}
}
}
}
}else{
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='".$id."'");
$arr_color=explode(",",$msg["color"]);
$arr_size=explode(",",$msg["size"]);
$arr_color_ka=explode(",",$msg["color_ka"]);
//检测配码
$arr_pm_id=array();
for($i1=0;$i1<count($arr_str_sub);$i1++){
$arr_tmp=explode("|",$arr_str_sub[$i1]);
$arr_gz=explode(":",$arr_tmp[1]);
$arr_tmp1=explode("_",$arr_tmp[0]);
for($j=0;$j<count($arr_gz);$j++){
$tmp_num=$arr_gz[$j]*$arr_tmp[2];
//到到版型尺码的数量
//$v="num_".$arr_tmp1[0]."_".$arr_tmp1[1]."_".$arr_size[$j];
$v="num_".$arr_tmp1[0]."_".$arr_size[$j];
$$v+=$tmp_num;
//echo $v.":".$$v."<br>";
}
$tmp_num=count_pm_num($arr_tmp[1])*$arr_tmp[2];
//到颜色的数量
$v1="color_num_".$arr_tmp1[0];
$$v1+=$tmp_num;
//到颜色版型的数量
$v2="color_bx_num_".$arr_tmp1[0]."_".$arr_tmp1[1];
$$v2+=$tmp_num;
$tmp_total_num+=$tmp_num;
}
$h=1;
$arr_uid=array();
//print_r($arr_str_sub);
for($i1=0;$i1<count($arr_str_sub);$i1++){
$arr_tmp=explode("|",$arr_str_sub[$i1]);
//print_r($arr_tmp);
$tmp_client=get_db_msg("select * from ".$table_pre."client where id='".$arr_tmp[0]."'");
//echo $tmp_client["face"];
if($tmp_client["face"]=="4"){
$arr_uid[$arr_tmp[0]]=$arr_tmp[0];
//
$is_save="y";
if($msg_login["qyjl_order"]=="b" && !preg_match($partten,$tmp_client["title"]))
$is_save="n";
if($is_brand=="y"){
//启用多品牌
$check1=get_db_msg("select id,is_jd,is_checked from ".$table_pre."client_brand where cid='".$tmp_client["id"]."' and brand='".$msg["brand"]."'");
if($check1["is_jd"]=="y"){
$is_save="n";
}
if($check1["is_checked"]=="y"){
$is_save="n";
}
if($check1["id"]>0){
//有权限
}else{
$is_save="n";
}
}else{
if($tmp_client["is_jd"]=="y"){
$is_save="n";
}
if($tmp_client["is_checked"]=="y"){
$is_save="n";
}
}
//echo $tmp_client["title"]."-".$is_save."|";
if($is_save=="y"){
$tmp_uid=$arr_tmp[0];
$qy_uid=get_qy_id($tmp_client["path"]);
$arr_gz=explode(":",$arr_tmp[1]);
$num=count_pm_num($arr_tmp[1]);
if($num>0){
//取得配码id
$m_pm=get_db_msg("select id from ".$table_pre."size_pm where uid='".$tmp_client["id"]."' and khid='".$msg["id"]."' and gz='".$arr_tmp[1]."'");
//echo "select id from ".$table_pre."size_pm where uid='".$tmp_client["id"]."' and khid='".$msg["id"]."' and gz='".$arr_tmp[1]."';";
if($m_pm["id"]>0){
$pmid1=$m_pm["id"];
}else{
$tmp=get_db_msg("select title from ".$table_pre."size_pm where gz='".$arr_tmp[1]."' and (uid='".$uid."' or uid='')");
if($tmp["title"])
$pm_title=$tmp["title"];
else
$pm_title="临时".get_rand_num(4);
$q="insert into ".$table_pre."size_pm (qyid,uid,size_group_id,pm_dj,khid,title,gz,num) values ('".$qy_uid."','".$tmp_client["id"]."','".$msg["size_group"]."','临时配码','".$msg["id"]."','".$pm_title."','".$arr_tmp[1]."','".$num."')";
$db->query($q);
$pmid1=$db->insert_id();
}
$arr_pm_id[$i1]=$pmid1;
}else{
//$msg_client.=$tmp_client["title"]."请输入尺码!|";
$arr_pm_id[$i1]="";
//alert_and_back("请输入尺码!");
}
$tmp_upath=$arr_tmp["path"]."-".$arr_tmp["id"];
if(!in_array($color,$arr_color_ka)){
$sql_size1=$sql_size2=$sql_size3="";
$c=0;
for($k=0;$k<count($arr_size);$k++){
$v="num_".$tmp_uid."_".$arr_size[$k];
$c+=$$v;
$sql_size1.="num_".$arr_size[$k]."='".$$v."',";
$sql_size2.=",'".$$v."'";
$sql_size3.=",num_".$arr_size[$k];
}
$check=get_db_msg("select id from ".$table_pre."order where _key='".$sys_this_order_flag."' and uid='".$tmp_uid."' and iid='".$id."' and color='".$color."'");
if($check["id"]){
if($c>0){
$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($tmp_uid,$id,$color,$bx);
}else{
$q="delete from ".$table_pre."order where id='".$check["id"]."'";
$db->query($q);
}
}else{
if($c>0){
$sql1=$sql2="";
for($i11=0;$i11<count($arr_select_no);$i11++){
$sql1.=$arr_select_no[$i11].",";
$sql2.="'".$msg[$arr_select_no[$i11]]."',";
}
$q="insert into ".$table_pre."order (uid,upath,iid,no,".$sql1."jgd,color,bx,is_sp,size_group_id".$sql_size3.",_key,sx,add_date) values ('".$tmp_uid."','".$tmp_upath."','".$id."','".$msg["no"]."',".$sql2."'".get_jgd($msg["price"])."','".$color."','".$bx."','".$msg["is_sp"]."','".$msg["size_group"]."'".$sql_size2.",'".$sys_this_order_flag."','".get_sx($arr_color[$i])."','".time()."')";
$db->query($q);
cache_order($tmp_uid,$id,$color,$bx);
}
}
count_ph($tmp_uid,$id,$color);
set_order_total($tmp_uid);
}
//$db->query("delete from ".$table_pre."order_pm where uid='".$tmp_uid."' and iid='".$id."' and color='".$color."' and bx='".$bx."'");
}
}
$h++;
}
}
//$json_data.="\"strq\":\"".$strq."\",";
if($sys_ver_hy=="xz"){
foreach($arr_uid as $k => $v){
$db->query("delete from ".$table_pre."order_pm where uid='".$v."' and iid='".$id."' and color='".$color."' and bx='".$bx."'");
}
//保存配码信息
for($i1=0;$i1<count($arr_str_sub);$i1++){
if($arr_pm_id[$i1]!=""){
$arr_tmp=explode("|",$arr_str_sub[$i1]);
$q="insert into ".$table_pre."order_pm (_key,uid,iid,color,bx,pmid,xs) values ('".$sys_this_order_flag."','".$arr_tmp[0]."','".$id."','".$color."','".$bx."','".$arr_pm_id[$i1]."','".$arr_tmp[2]."')";
$db->query($q);
}
}
}
$json_data.="\"code\":101,";
if($msg_client){
$msg_client=substr($msg_client,0,-1);
$json_data.="\"msg\":\"".$msg_client."\",";
}else{
//$json_data.="\"errmsg\":\"\",";
}
}
/*if($is_window=="n"){
if($go_url){
url_redirect($go_url);
}else{
echo "<script>
if(window.parent)
window.parent.location.href='".$rurl."&auto_dialog=n';
else
window.location.href='".$rurl."&auto_dialog=n';
</script>";
}
}else{
if($go_url){
$url=$go_url;
}else{
$url=$rurl?$rurl:$_SERVER["PHP_SELF"];
}
url_redirect($url);
}*/
break;
case "save_pm":
$errmsg=check_pm_gz($pm_gz);
if($errmsg){
$json_data.="\"code\":0,\"msg\":\"".$errmsg."\",";
}else{
$title=trim($pm_title);
$check=get_db_msg("select * from ".$table_pre."size_pm where uid='".$uid."' and size_group_id='".$size_group_id."'");
$gz=deel_pm_gz($pm_gz);
$qy_uid=get_qy_id($msg_login["path"]);
$num=count_pm_num($gz);
if($check["id"]>0){
if($khid){
$q="update ".$table_pre."size_pm set title='".$title."',gz='".$gz."' where id='".$check["id"]."' and khid='".$khid."'";
}else{
$q="update ".$table_pre."size_pm set title='".$title."',gz='".$gz."' where id='".$check["id"]."'";
}
}else{
if($khid){
$q="insert into ".$table_pre."size_pm (qyid,uid,khid,size_group_id,title,gz,num) values ('".$qy_uid."','".$uid."','".$khid."','".$size_group_id."','".$title."','".$gz."','".$num."')";
}else{
$q="insert into ".$table_pre."size_pm (qyid,uid,size_group_id,title,gz) values ('".$qy_uid."','".$uid."','".$size_group_id."','".$title."','".$gz."')";
}
}
$db->query($q);
$json_data.="\"code\":101,";
}
//echo "success";
//exit;
break;
case "del_pm":
$title=trim($pm_title);
if($khid){
$q="delete from ".$table_pre."size_pm where uid='".$uid."' and khid='".$khid."' and size_group_id='".$size_group_id."'";
}else{
$q="delete from ".$table_pre."size_pm where uid='".$uid."' and size_group_id='".$size_group_id."'";
}
$db->query($q);
$json_data.="\"code\":101,";
//echo "success";
//exit;
break;
case "del":
$errmsg="";
$id=$khid;
//删除订单
if($order_close=="y"){
//alert_and_back("删除订单失败,原因是系统订单已经关闭!");
$errmsg="删除订单失败,原因是系统订单已经关闭!";
}
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
$is_xd_clothes="y";
$msg_size_group=get_db_msg("select title from ".$table_pre."keyword where cate='size' and id='".$msg["size_group"]."'");
if(in_array($msg_size_group["title"],$sys_size_group_xz))
$is_xd_clothes="n";
//取得店铺等级
$arr_dpdj=array();
$arr_dpdj_dp=array();
$arr_all_dp=array();
$tmpdpdj="{\"dj\":\"_ALL_\",\"title\":\"所有店铺\"},";
$j=0;
for($i=0;$i<count($arr_upath);$i++){
$tmp_uid=get_parent_id($arr_upath[$i]);
$tmp=get_db_msg("select dj,face from ".$table_pre."client where id='".$tmp_uid."'");
if($tmp["face"]=="4"){
$arr_dpdj_dp[$tmp["dj"]][]=$tmp_uid;
if($tmp["dj"]!="" && !in_array($tmp["dj"],$arr_dpdj)){
$arr_dpdj[$tmp["dj"]]=$tmp["dj"];
$tmpdpdj.="{\"dj\":\"".$tmp["dj"]."\",\"title\":\"".$tmp["dj"]."\"},";
if($s_dpdj=="" && $j==0)
$s_dpdj=$tmp["dj"];
$j++;
}
$arr_all_dp[]=$tmp_uid;
}
}
$tmpdpdj=deel_end($tmpdpdj);
//$json_data.="\"s_dpdj\":[".$tmpdpdj."],";
//取得店铺
$arr_dp=array();
foreach($arr_dpdj_dp as $dj1 => $arr_dp1){
if($s_dpdj=="_ALL_"){
$arr_dp=$arr_all_dp;
}else{
if($dj1==$s_dpdj){
$arr_dp=$arr_dp1;
}
}
}
for($i=0;$i<count($arr_dp);$i++){
$tmp_uid=$arr_dp[$i];
$q="select * from ".$table_pre."client where id='".$tmp_uid."'";
//echo $q."<Br>";
$m=get_db_msg($q);
if($m["face"]=="4"){
$is_save="y";
if($msg_login["qyjl_order"]=="b" && !preg_match($partten,$m["title"]))
$is_save="n";
if($is_brand=="y"){
//启用多品牌
$check1=get_db_msg("select id,is_jd,is_checked from ".$table_pre."client_brand where cid='".$m["id"]."' and brand='".$msg["brand"]."'");
if($check1["is_jd"]=="y"){
$is_save="n";
}
if($check1["is_checked"]=="y"){
$is_save="n";
}
if($check1["id"]>0){
//有权限
}else{
$is_save="n";
}
}else{
if($m["is_jd"]=="y"){
$is_save="n";
}
if($m["is_checked"]=="y"){
$is_save="n";
}
}
if($is_save=="y"){
$q="delete from ".$table_pre."order where uid='".$m["id"]."' and iid='".$id."' and color='".$color."' and bx='".$bx."' and _key='".$_key."'";
$db->query($q);
//删除订单配码表
//判断是否采用服装版本下单
if($is_xd_clothes=="n"){
$db->query("delete from ".$table_pre."order_pm where _key='".$_key."' and uid='".$m["id"]."' and iid='".$id."' and color='".$color."' and bx='".$bx."'");
}
update_order_log($m["id"],"delete from ".$table_pre."order where uid='".$m["id"]."' and iid='".$id."' and color='".$color."' and bx='".$bx."' and _key='".$_key."'");
set_order_total($m["id"]);
}
}
}
$json_data.="\"code\":101,";
//
/*if($is_window=="n"){
if($go_url){
url_redirect($go_url);
}else{
echo "<script>
if(window.parent)
window.parent.location.href='".$rurl."&auto_dialog=n';
else
window.location.href='".$rurl."&auto_dialog=n';
</script>";
}
}else{
if($go_url){
$url=$go_url;
}else{
$url=$rurl?$rurl:$_SERVER[PHP_SELF];
}
url_redirect($url);
}*/
//echo "<meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\"><script> alert('删除订单成功!'); window.parent.location.reload(); </script>";
break;
case "single":
$json_data.="\"sys_ck_input\":\"".$sys_ck_input."\",";
$is_pm=get_set("is_pm");
$json_data.="\"is_pm\":\"".$is_pm."\",";
$json_data.="\"khid\":\"".$khid."\",";
$json_data.="\"color\":\"".$color."\",";
$json_data.="\"bx\":\"".$bx."\",";
$json_data.="\"qjqx\":\"".$msg_login["qyjl_order"]."\",";
$id=$khid;
//
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
//判断是否采用服装版本下单
$is_xd_clothes="y";
$msg_size_group=get_db_msg("select title from ".$table_pre."keyword where cate='size' and id='".$msg["size_group"]."'");
if(in_array($msg_size_group["title"],$sys_size_group_xz))
$is_xd_clothes="n";
$json_data.="\"is_xd_clothes\":\"".$is_xd_clothes."\",";
//
if($xh_ms=="2"){
//序号到色
$msg_kh_xh=get_db_msg("select xh from ".$table_pre."kh_xh where kh='".$msg["no"]."' and color='".$color."' limit 0,1");
$_xh=$msg_kh_xh["xh"];
}else{
//序号查询定制
$_xh=$msg["xh"];
}
$err_msg="";
//
if(!$msg["id"])
$err_msg="记录不存在";
if($err_msg){
$json_data.="\"error\":\"".$err_msg."\",";
}else{
$json_data.="\"code\":100,";
if($order_close=="y")
$msg_tip="对不起,暂时关闭订单功能!";
$is_ggk=is_ggk($msg["id"]);
$json_data.="\"is_ggk\":\"".$is_ggk."\",";
//是否为删除色
$arr_color=explode(",",$msg["color"]);
$arr_color_ka=explode(",",$msg["color_ka"]);
$is_ka="n";
for($i=0;$i<count($arr_color_ka);$i++){
if($arr_color_ka[$i]==$color){
$is_ka="y";
break;
}
}
$json_data.="\"xh\":\"".$_xh."\",";
$json_data.="\"kh\":\"".$msg["no"]."\",";
if($msg["size_group"]==$child_sizegroup_id){
//童装尺码异价
foreach($arr_child_bx as $bx1 => $size1){
$m1=get_db_msg("select id,price from ".$table_pre."size_bx where no='".$msg["no"]."' and bx='".$bx1."'");
if($m1["id"]>0){
$price_zk=get_price_zk($uid,$msg["id"],'',$bx1);
$str_price.=$bx1.": ".$m1["price"]."";
if($price_zk!=$m1["price"])
$str_price.=" / 结算价:".$price_zk."";
$str_price.="<br>";
}
}
}else{
$dp_price=get_price_dp($uid,$msg["id"]);
$str_price=deel_num($dp_price)."";
$price_zk=get_price_zk($uid,$msg["id"]);
if($price_zk!=$dp_price){
$str_price.=" / 结算价:".deel_num($price_zk)."";
}
//买断价
$tmp=get_db_msg("select id,price from ".$table_pre."kh_md where (dj='".$msg_login["dj"]."' or dj='') and kh='".$msg["no"]."' limit 0,1");
if($tmp["id"]>0){
$price_md=$tmp["price"]>0?$tmp["price"]:$price_zk;
$str_price.=" / ".d_translate("md")."价:".deel_num($price_md)."";
}
}
$json_data.="\"price\":\"".$str_price."\",";
//$json_data.="\"price\":\"".$msg["price"]."\",";
$json_data.="\"is_ka\":\"".$is_ka."\",";
//-------------------设置禁止提交表单
if($order_close=="y" || $is_ka=="y"){
$disable=" disabled";
}else{
$disable="";
}
$json_data.="\"disable\":\"".$disable."\",";
//取得评级
$msg_pj=get_db_msg("select * from ".$table_pre."client_pj where khid='".$id."' and cid='".$uid."'");
if($msg_pj["id"]>0){
$pj_remark=dhtmlchars($msg_pj["remark"]);
$race=$msg_pj["race"];
}else{
$pj_remark="";
$race=0;
}
$q="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and flag_bd='n' and no<>'jgd' and no<>'sx' and no<>'color' order by ord";
$r=$db->query($q);
$i=0;
$zds="";
while($m=$db->fetch_array($r)){
$str_select_dz.="\"".$m["title"]."|";
if($m["no"]=="zd1" || $m["no"]=="zd2" || $m["no"]=="zd3"){
//$str_select_dz.=$msg[$m["no"]]."\",";
//$zds.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
}else{
//$str_select_dz.=deel_js_var(get_cate_title_no($m["no"],$msg[$m["no"]]))."\",";
$zds.="{\"no\":\"".$i."\",\"title\":\"".get_cate_title_no("arr_select",$m["no"])."\",\"value\":\"".get_cate_title_no($m["no"],$msg[$m["no"]])."\"},";
}
$i++;
}
$zds=deel_end($zds);
$json_data.="\"zds\":[".$zds."],";
$json_data.="\"xj\":\"".$race."\",";
$json_data.="\"ksm\":\"".$msg["title"]."\",";
$json_data.="\"pjwz\":\"".$pj_remark."\",";
$json_data.="\"size_group_id\":\"".$msg["size_group"]."\",";
$pj_icon=get_pj_icon($race,$id,'big');
//-------------------设置提示信息
if($msg["size_group"]==$bx_sizegroup_id){
$arrBx=array();
$tmp=get_db_msg("select * from ".$table_pre."size_bx where no='".$msg["no"]."' and bx='".$bx."'");
$arr_size=explode(",",$tmp["size"]);
}else{
$arr_size=explode(",",$msg["size"]);
}
$total=0;
$js_check_str="";
$str_color="";
//取得数量
$input_width=get_input_width(count($arr_size));
$json_data.="\"input_width\":\"".$input_width."\",";
$arr_tr=array();
$ind=11;
$xxhj=0;
$arr_ct=$arr_ct1="";
//取得店铺等级
$arr_dpdj=array();
$arr_dpdj_dp=array();
$arr_all_dp=array();
$tmpdpdj="{\"dj\":\"_ALL_\",\"title\":\"所有店铺\"},";
$j=0;
for($i=0;$i<count($arr_upath);$i++){
$tmp_uid=get_parent_id($arr_upath[$i]);
$tmp=get_db_msg("select dj,face from ".$table_pre."client where id='".$tmp_uid."'");
if($tmp["face"]=="4"){
$arr_dpdj_dp[$tmp["dj"]][]=$tmp_uid;
if($tmp["dj"]!="" && !in_array($tmp["dj"],$arr_dpdj)){
$arr_dpdj[$tmp["dj"]]=$tmp["dj"];
$tmpdpdj.="{\"dj\":\"".$tmp["dj"]."\",\"title\":\"".$tmp["dj"]."\"},";
if($s_dpdj=="" && $j==0)
$s_dpdj=$tmp["dj"];
$j++;
}
$arr_all_dp[]=$tmp_uid;
}
}
$tmpdpdj=deel_end($tmpdpdj);
$json_data.="\"s_dpdj\":[".$tmpdpdj."],";
//取得店铺
$arr_dp=array();
foreach($arr_dpdj_dp as $dj1 => $arr_dp1){
if($s_dpdj=="_ALL_"){
$arr_dp=$arr_all_dp;
}else{
if($dj1==$s_dpdj){
$arr_dp=$arr_dp1;
}
}
}
for($i=0;$i<count($arr_dp);$i++){
//删除款不允许下单
if(in_array($color,$arr_color_ka)){
$disable_color=" disabled";
$sty1="font-weight:bold;color:#ff0000;";
$link_ds="";
}else{
$sty1="";
$disable_color=$disable;
$link_ds="";
}
$tr_bg="#ffffff";
$tmp_uid=$arr_dp[$i];
$q="select id,face,dj,title,username,is_jd,is_checked from ".$table_pre."client where id='".$tmp_uid."'";
//echo $q."<Br>";
$m=get_db_msg($q);
if($m["face"]=="4"){
$bh="n";
//如果是备货账号,把备货店铺放到第一行
if($msg_login["qyjl_order"]=="b" && preg_match($partten,$m["title"])){
$ind2=1;
$bh="y";
}else{
if($msg_login["qyjl_order"]=="b")
$disable_color=" disabled";
$ind2=0;
$ind++;
}
$ind1=($ind2>0)?$ind2:$ind;
//判断是否有订货权限,是否交单
$msg_tip="";
if($is_brand=="y"){
//启用多品牌
$check1=get_db_msg("select id,is_jd,is_checked from ".$table_pre."client_brand where cid='".$m["id"]."' and brand='".$msg["brand"]."'");
if($check1["is_jd"]=="y"){
$disable_color=" disabled";
$msg_tip="已交单";
}
if($check1["is_checked"]=="y"){
$disable_color=" disabled";
$msg_tip="已确认";
}
if($check1["id"]>0){
//有权限
}else{
//无权订货
$disable_color=" disabled";
$sty1="";
$link_ds="无订货权限";
}
}else{
if($m["is_jd"]=="y"){
$disable_color=" disabled";
$msg_tip="已交单";
}
if($m["is_checked"]=="y"){
$disable_color=" disabled";
$msg_tip="已确认";
}
}
if($is_xd_clothes=="y"){
$str_color.=$m["id"].",";
//起订量
$client_dj=trim($m["dj"]);
$con_dj=$client_dj?" and (dj='".$client_dj."' or dj='')":" and dj=''";
$qdl=get_db_msg("select num from ".$table_pre."gz where cate='qdl' and kh='".$msg["no"]."' and color='".$color."'".$con_dj);
if($qdl["num"]>0)
$str_qdl="起订量".$qdl["num"]."";
else
$str_qdl="";
$arr_tr[$ind1]="<tr><td bgcolor=\"".$tr_bg."\" align=\"right\"><span style=\"".$sty1."\">".$m["title"]."(".$m["username"].")</span>".$msg_tip.$str_qdl.$link_ds."</td>";
if($is_pm=="y")
$arr_tr[$ind1].="<td bgcolor=\"".$tr_bg."\" align=\"center\"><input type=\"number\" name=\"pm_".$m["id"]."_".$bx."\" id=\"pm_".$m["id"]."_".$bx."\" style=\"width:".$input_width."px;background-color:#f6f6f6;border:1px solid #cccccc;\" onchange=\"input_pm(this.name);re_count_pm(this.name);\"></td>";
$m1=get_db_msg("select * from ".$table_pre."order where uid='".$tmp_uid."' and iid='".$msg["id"]."' and color='".$color."' and bx='".$bx."' and _key='".$_key."'");
$s_xj=0;
if($bh=="y"){
$arr_ct1.="{\"id\":\"".$m["id"]."\",\"kh\":\"".$msg["no"]."\",\"color\":\"".$color."\",\"bx\":\"".$bx."\",\"title\":\"".$m["title"]."\",\"username\":\"".$m["username"]."\",\"uid\":\"".$tmp_uid."\",\"msg_tip\":\"".$msg_tip."\",\"str_qdl\":\"".$str_qdl."\",\"link_ds\":\"".$link_ds."\",\"sty1\":\"".$sty1."\",\"disable_color\":\"".$disable_color."\",";
}else{
$arr_ct.="{\"id\":\"".$m["id"]."\",\"kh\":\"".$msg["no"]."\",\"color\":\"".$color."\",\"bx\":\"".$bx."\",\"title\":\"".$m["title"]."\",\"username\":\"".$m["username"]."\",\"uid\":\"".$tmp_uid."\",\"msg_tip\":\"".$msg_tip."\",\"str_qdl\":\"".$str_qdl."\",\"link_ds\":\"".$link_ds."\",\"sty1\":\"".$sty1."\",\"disable_color\":\"".$disable_color."\",";
}
$arr_sz="";
for($k=0;$k<count($arr_size);$k++){
//取得客户尺码订单
$num1=$m1["num_".$arr_size[$k]];
if($msg_login["qyjl_order"]=="b" && preg_match($partten,$m["title"])){
//备货账号不计算
}else{
$var1="xxhj_num_".$arr_size[$k];
$$var1+=$num1;
$xxhj+=$num1;
}
$js_check_str.=$num1.",";
$s_xj+=$num1;
$bg_input_num=(check_md($msg["no"],$color,$bx,$arr_size[$k],$msg_login["dj"])=="n")?"#ffffff":"#00ff00";
if(check_size_not($msg["no"],$color,$bx,$arr_size[$k])=="y"){
$disable_color1=" disabled";
$bg_input_num="#cccccc";
}else{
$disable_color1=$disable_color;
}
$arr_tr[$ind1].="<td bgcolor=\"#ffffff\"><input type=\"number\" id=\"num_".$m["id"]."_".$bx."_".$arr_size[$k]."\" name=\"num_".$m["id"]."_".$bx."_".$arr_size[$k]."\" value=\"".deel_0($num1)."\" style=\"width:".$input_width."px;font-size:14px;background-color:".$bg_input_num.";\" onchange=\"re_count(this.name);this.value=this.value.replace(/\D/g,'0');\"".$disable_color1." /></td>";
$arr_sz.="{\"id\":\"num_".$m["id"]."_".$bx."_".$arr_size[$k]."\",\"value\":\"".deel_0($num1)."\",\"disable_color1\":\"".$disable_color1."\",\"bg_input_num\":\"".$bg_input_num."\",\"size\":\"".$arr_size[$k]."\"},";
//合计尺码数量
$var_xj_size="xj_size_".$arr_size[$k];
$$var_xj_size+=$num1;
$j++;
}
}else{
//取得装箱数
$q1="select num from ".$table_pre."gz where cate='zxs' and (dj='".$msg_login["username"]."' or dj='') and kh='".$msg["no"]."' order by num";
//echo $q1;
$r1=$db->query($q1);
$sql_pm="";
$str_zxs="";
while($m1=$db->fetch_array($r1)){
$sql_pm.="num='".$m1["num"]."' or ";
//$str_zxs.="{\"zxs\":\"".$m1["num"]."\"},";
$str_zxs.=$m1["num"].",";
}
if($str_zxs){
$str_zxs=deel_end($str_zxs);
}
$json_data.="\"zxs\":\"".$str_zxs."\",";
$tmp1=get_db_msg("select count(*) 'num' from ".$table_pre."order_pm where _key='".$sys_this_order_flag."' and uid='".$tmp_uid."' and iid='".$msg["id"]."' and color='".$color."'");
if($tmp1["num"]>0)
$colspan1=$tmp1["num"]+1;
else
$colspan1=1;
//取得该颜色的配码信息
$q1="select * from ".$table_pre."order_pm where _key='".$sys_this_order_flag."' and uid='".$tmp_uid."' and iid='".$msg["id"]."' and color='".$color."' order by id";
$r1=$db->query($q1);
$j1=0;
$arr_sz="";
while($m1=$db->fetch_array($r1)){
$tmp=get_db_msg("select title,gz from ".$table_pre."size_pm where id='".$m1["pmid"]."'");
$tmp_num=$m1["xs"]*count_pm_num($tmp["gz"]);
//$num_arr.="[\"".$tmp_uid."|".$m_dp["title"]."\",".$j1.",\"".$tmp["title"]."|".$tmp["gz"]."\",".$m1["xs"].",\"".$is_ka."\",\"".$is_selected."\"],";
$arr_sz.="{\"xh\":\"".$j1."\",\"pmt\":\"".$tmp["title"]."\",\"pm\":\"".$tmp["gz"]."\",\"xs\":".$m1["xs"].",\"num\":".$tmp_num."},";
$total_xs+=$m1["xs"];
$total_num+=$tmp_num;
$j1++;
}
if($j1==0){
$str_color_hang.=($j1+1).",";
$j1++;
//$num_arr.="[\"".$tmp_uid."|".$m_dp["title"]."\",0,\"|\",0,\"".$is_ka."\",\"".$is_selected."\"],";
}else{
$str_color_hang.=$j1.",";
}
if($bh=="y"){
$arr_ct1.="{\"id\":\"".$m["id"]."\",\"kh\":\"".$msg["no"]."\",\"color\":\"".$color."\",\"bx\":\"".$bx."\",\"title\":\"".$m["title"]."\",\"username\":\"".$m["username"]."\",\"uid\":\"".$tmp_uid."\",\"msg_tip\":\"".$msg_tip."\",\"str_qdl\":\"".$str_qdl."\",\"link_ds\":\"".$link_ds."\",\"sty1\":\"".$sty1."\",\"disable_color\":\"".$disable_color."\",\"count\":".$j1.",";
}else{
$arr_ct.="{\"id\":\"".$m["id"]."\",\"kh\":\"".$msg["no"]."\",\"color\":\"".$color."\",\"bx\":\"".$bx."\",\"title\":\"".$m["title"]."\",\"username\":\"".$m["username"]."\",\"uid\":\"".$tmp_uid."\",\"msg_tip\":\"".$msg_tip."\",\"str_qdl\":\"".$str_qdl."\",\"link_ds\":\"".$link_ds."\",\"sty1\":\"".$sty1."\",\"disable_color\":\"".$disable_color."\",\"count\":".$j1.",";
}
}
$arr_sz=substr($arr_sz,0,-1);
if($bh=="y"){
$arr_ct1.="\"arr_size\":[".$arr_sz."],";
$arr_ct1.="\"size_count\":\"".count($arr_size)."\"},";
}else{
$arr_ct.="\"arr_size\":[".$arr_sz."],";
$arr_ct.="\"size_count\":\"".count($arr_size)."\"},";
}
$total+=$s_xj;
$arr_tr[$ind1].="<td bgcolor=\"#f0f0f0\"><div id=\"xj_".$m["id"]."_".$bx."\" name=\"xj_".$m["id"]."_".$bx."\" />".$s_xj."</div></td></tr>";
}
}
$arr_ct=substr($arr_ct,0,-1);
$json_data.="\"dds\":[".$arr_ct."],";
$arr_ct1=substr($arr_ct1,0,-1);
$json_data.="\"bhs\":[".$arr_ct1."],";
if($str_color)
$str_color=substr($str_color,0,-1);
$json_data.="\"str_color\":\"".$str_color."\",";
if($msg_login["qyjl_order"]=="b"){
//如果是备货账号,增加一行下线合计
$colspan=($is_pm=="y")?2:1;
$arr_tr[2]="<tr bgcolor=\"#e0e0e0\"><td align=\"right\" colspan='".$colspan."'>下线合计</td>";
$str_hj="";
for($k=0;$k<count($arr_size);$k++){
$var1="xxhj_num_".$arr_size[$k];
$arr_tr[2].="<td>".$$var1."</td>";
$str_hj.="{\"hj_num\":\"".$$var1."\"},";
}
$str_hj=substr($str_hj,0,-1);
$arr_tr[2].="<td>".$xxhj."</td></tr>";
$json_data.="\"size_xxhj\":[".$str_hj."],";
$json_data.="\"colspan\":\"".$colspan."\",";
$json_data.="\"xxhj\":\"".$xxhj."\",";
}
$json_data.="\"qyjl_order\":\"".$msg_login["qyjl_order"]."\",";
$json_data.="\"is_pm\":\"".$is_pm."\",";
ksort($arr_tr);
$str_num="";
foreach($arr_tr as $k => $str){
$str_num.=$str;
}
//----------------数量表
//表头
$str_size_title=$cmz="";
for($i=0;$i<count($arr_size);$i++){
$tmp=get_db_msg("select title from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$arr_size[$i]."'");
$str_size_title.=$arr_size[$i]."|".$tmp["title"].",";
$cmz.="{\"no\":\"".$arr_size[$i]."\",\"title\":\"".$tmp["title"]."\"},";
}
if($str_size_title)
$str_size_title=substr($str_size_title,0,-1);
$json_data.="\"str_size_title\":\"".$str_size_title."\",";
$cmz=deel_end($cmz);
$json_data.="\"cmz\":[".$cmz."],";
$content_num="<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"3\" bgcolor=\"#cccccc\"><tr><td align=\"right\" bgcolor=\"#f0f0f0\">客户</td>";
if($is_pm=="y")
$content_num.="<td align=\"center\" bgcolor=\"#f0f0f0\" width=\"30\">配码</td>";
$str_size_t="";
for($i=0;$i<count($arr_size);$i++){
$tmp=get_db_msg("select title from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$arr_size[$i]."'");
$content_num.="<td align=\"center\" bgcolor=\"#f0f0f0\" style=\"width:50px;\" width=\"50\">".$tmp["title"]."</td>";
$str_size_t.="{\"title\":\"".$tmp["title"]."\",\"no\":\"".$arr_size[$i]."\"},";
}
$str_size_t=substr($str_size_t,0,-1);
$json_data.="\"arr_size\":[".$str_size_t."],";
$content_num.="<td align=\"center\" bgcolor=\"#f0f0f0\" style=\"width:50px;\" width=\"50\">小计</td></tr>";
//内容
$content_num.=$str_num;
//合计
$colspan1=1;
if($is_pm=="y")
$colspan1++;
$content_num.="<tr><td align=\"right\" bgcolor=\"#f0f0f0\" height=\"30\" colspan=\"".$colspan1."\">合计</td>";
$str_hj="";
for($i=0;$i<count($arr_size);$i++){
$var_xj_size="xj_size_".$arr_size[$i];
$content_num.="<td align=\"center\" bgcolor=\"#f0f0f0\"><div id=\"xj_size_".$arr_size[$i]."\" />".$$var_xj_size."</div></td>";
$str_hj.="{\"hj_num\":\"".$$var_xj_size."\"},";
}
$str_hj=substr($str_hj,0,-1);
$json_data.="\"size_hj\":[".$str_hj."],";
$json_data.="\"colspan1\":\"".$colspan1."\",";
$json_data.="\"total\":\"".$total."\",";
$content_num.="<td bgcolor=\"#f0f0f0\" align=\"center\"><div id=\"total\" />".$total."</div></td></tr></table>";
if($js_check_str)
$js_check_str=substr($js_check_str,0,-1);
$json_data.="\"js_check_str\":\"".$js_check_str."\",";
//定义图片目录
$pathdir="../attachments/design/mini";
$json_data.="\"pathdir\":\"".$pathdir."\",";
if($flag_pad=="_pad"){
$s_pathdir_mini="content://com.muchuang.edt/attachments/design/mini";
$s_pathdir_big="content://com.muchuang.edt/attachments/design/big";
}else{
$s_pathdir_mini="../attachments/design/mini";
$s_pathdir_big="../attachments/design/big";
}
$json_data.="\"s_pathdir_mini\":\"".$s_pathdir_mini."\",";
$json_data.="\"s_pathdir_big\":\"".$s_pathdir_big."\",";
//--取得单款图片数组
$arr_pic="";
if($sys_close_image=="y"){
$pic_m1="images/no_pic.png";
$pic_b1="images/no_pic_big.png";
$arr_pic.="{\"color\":\"\",\"pic_m1\":\"".$pic_m1."\",\"m1_w\":\"\",\"m1_h\":\"\",\"pic_b1\":\"".$pic_b1.",\"b1_w\":\"\",\"b1_h\":\"\"},";
}else{
$pic_m1=get_kh_color_picture($msg["no"],$color,'');
$pic_b1=get_kh_color_picture_big($msg["no"],$color,'');
$tmpm=out_good_pic_set_arr($pic_m1,40,40);
$tmpb=out_good_pic_set_arr($pic_b1,$tmpl_order_single_w,$tmpl_order_single_h);
//$arr_pic.="\"".$color."|".$pic_m1."|".str_replace("\"",",",out_good_pic_set($pic_m1,40,40))."|".$pic_b1."|".str_replace("\"",",",out_good_pic_set($pic_b1,$tmpl_order_single_w,$tmpl_order_single_h))."\",";
$arr_pic.="{\"color\":\"".$color."\",\"pic\":\"".$pic_m1."\",\"pic_w\":".$tmpm[0].",\"pic_h\":".$tmpm[1].",\"pic_big\":\"".$pic_b1."\",\"pic_big_w\":\"".$tmpb[0]."\",\"pic_big_h\":\"".$tmpb[1]."\"},";
}
$arr_pic=substr($arr_pic,0,-1);
$json_data.="\"pics\":[".$arr_pic."],";
//--取得产品细节图
$arr_detail="";
if(check_table_exist($table_pre."pic_detail")=="y"){
$q1="select pic from ".$table_pre."pic_detail where kh='".$msg["no"]."' order by pic";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$f=$s_pathdir_mini."/".$m1["pic"];
$f1=$s_pathdir_big."/".$m1["pic"];
$tmpwh=out_good_pic_set_arr($pathdir."/".$m1["pic"],120,120);
$arr_detail.="{\"pic\":\"".$f1."\",\"pic_big\":\"".$f."\",\"pic_w\":".$tmpwh[0].",\"pic_h\":".$tmpwh[1]."},";
$i++;
}
}
$arr_detail=substr($arr_detail,0,-1);
$json_data.="\"xjs\":[".$arr_detail."],";
//--搭配款
$arr_cc="[]";
$arr_dp="[]";
$arr_cl="[]";
$arr_dpk="[]";
if($first_act)
$js_onload=" onload=\"".$first_act."\"";
$json_data.="\"js_onload\":\"".$js_onload."\",";
//上一款、下一款
if($xh_ms=="2"){
$pre_xh=get_db_msg("select b.id 'id' from ".$table_pre."kh_xh a,".$table_pre."kh b where a.kh=b.no and a.xh<'".$_xh."' and a.kh<>'".$msg["no"]."' order by a.xh desc limit 0,1");
$next_xh=get_db_msg("select b.id 'id' from ".$table_pre."kh_xh a,".$table_pre."kh b where a.kh=b.no and a.xh>'".$_xh."' and a.kh<>'".$msg["no"]."' order by a.xh limit 0,1");
}else{
$pre_xh=get_db_msg("select id from ".$table_pre."kh where xh<'".$_xh."' and no<>'".$msg["no"]."' order by xh desc limit 0,1");
$next_xh=get_db_msg("select id from ".$table_pre."kh where xh>'".$_xh."' and no<>'".$msg["no"]."' order by xh limit 0,1");
}
$str_sxk="[\"".$pre_xh["id"]."\",\"".$next_xh["id"]."\"]";
$json_data.="\"prev\":\"".$pre_xh["id"]."\",";
$json_data.="\"next\":\"".$next_xh["id"]."\",";
//取得定制选项
$select_dz=array();
$q="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and flag_bd='n' and no<>'jgd' and no<>'sx' and no<>'color' order by ord";
$r=$db->query($q);
$i=0;
$str_select_dz="";
while($m=$db->fetch_array($r)){
$select_dz[$i][0]=$m["title"].":";
$str_select_dz.="{\"title\":\"".$m["title"]."\",";
if($m["no"]=="zd1" || $m["no"]=="zd2" || $m["no"]=="zd3"){
$select_dz[$i][1]=$msg[$m["no"]];
$str_select_dz.="\"value\":\"".$msg[$m["no"]]."\"},";
}else{
$select_dz[$i][1]=get_cate_title_no($m["no"],$msg[$m["no"]]);
$str_select_dz.="\"value\":\"".get_cate_title_no($m["no"],$msg[$m["no"]])."\"},";
}
$i++;
}
$str_select_dz=substr($str_select_dz,0,-1);
$json_data.="\"select_dz\":[".$str_select_dz."],";
//取得配码信息
$json_data.="\"pm_ms\":\"".$pm_ms."\",";
$json_data.="\"pmkg\":\"".$pm_ms."\",";
if($pm_ms!="n"){
if($msg["size_group"]==$child_sizegroup_id){
//童装配码规则,如果启用后台配码,并且有配码,只能配码输入。
$default_pm_id=0;
$default_pm="";
//取得所有适合我的配码
$pm_op="";
$i=0;
foreach($arr_child_bx as $bx1 => $arr_bx_size1){
$con1="bx='".$bx1."' and ((uid='0' and dlid=0 and qyid=0) or (uid='".$uid."')) and (khid='".$msg["id"]."' or (khid='0' and size_group_id='".$msg["size_group"]."'))";
$str_pm1="";
$m=get_db_msg("select id,title,gz from ".$table_pre."size_pm where ".$con1." order by uid desc,size_group_id desc limit 0,1");
if($m["id"]>0)
$pm_op.="{\"xh\":\"".$i."\",\"bx\":\"".$bx1."\",\"gz\":\"".$m["gz"]."\",\"title\":\"".$m["title"]."\",\"id\":\"".$m["id"]."\"},";
else
$pm_op.="{\"xh\":\"".$i."\",\"bx\":\"".$bx1."\",\"gz\":\"\",\"title\":\"\",\"id\":\"\"},";
$i++;
}
$pm_op.="";
}else{
//默认匹配规则
$default_pm_id=0;
$default_pm="";
//取得所有适合我的配码
$pm_op="";
$pm_op_value=$default_pm_id;
$con1="((uid='0' and dlid=0 and qyid=0) or (uid='".$uid."')) and (khid='".$msg["id"]."' or (khid='0' and size_group_id='".$msg["size_group"]."'))";
$q="select id,title,gz from ".$table_pre."size_pm where ".$con1." order by uid desc,size_group_id desc,id desc";
$r=$db->query($q);
$i=0;
while($m=$db->fetch_array($r)){
$pm_op.="{\"gz\":\"".$m["gz"]."\",\"title\":\"".$m["title"]."\",\"id\":\"".$m["id"]."\"},";
if($i==0){
$default_pm_id=$m["id"];
$default_pm=$m["gz"];
}
$i++;
}
if($i==0)
$pm_op.="{},";
$pm_op.="";
$str_pm_num=$str_pm_gz="";
if($default_pm){
$str_pm_gz=$default_pm;
$num_pm=0;
$arr1=explode(":",$default_pm);
for($i=0;$i<count($arr1);$i++){
$num_pm+=$arr1[$i];
}
if($num_pm>0)
$str_pm_num="=".$num_pm;
}
$pg_gz_w=count($arr_size)*13;
$content_pm="";
//取得尺码组名称
$tmp=get_db_msg("select title from ".$table_pre."keyword where id='".$msg["size_group"]."'");
$size_group_title=$tmp["title"];
$json_data.="\"size_group_title\":\"".$size_group_title."\",";
$json_data.="\"pg_gz_w\":\"".$pg_gz_w."\",";
$json_data.="\"str_pm_gz\":\"".$str_pm_gz."\",";
$json_data.="\"str_pm_num\":\"".$str_pm_num."\",";
$json_data.="\"default_pm_id\":\"".$default_pm_id."\",";
$json_data.="\"default_pm\":\"".$default_pm."\",";
}
}
$pm_op=substr($pm_op,0,-1);
$json_data.="\"pms\":[".$pm_op."],";
$json_data.="\"translate_xh\":\"".d_translate("xh")."\",";
$json_data.="\"translate_gg\":\"".d_translate("gg")."\",";
$json_data.="\"translate_dhbs\":\"".d_translate("dhbs")."\",";
$json_data.="\"translate_dpk\":\"".d_translate("dpk")."\",";
$json_data.="\"translate_xgdp\":\"".d_translate("xgdp")."\",";
//include_once $path_dz."/dp/order_single.php";
//显示颜色,杯型
$str_other_info="";
$other_info="<table border=0 cellspacing=1 cellpadding=4 bgcolor='#cccccc'>";
$other_info.="<tr bgcolor='#ffffff'><td><div>颜色:<span class='order_single_text'>".get_cate_title_no("color",$color)."</span><br>";
$str_other_info.="{\"color\":\"".$color."\",";
if($msg["size_group"]==$bx_sizegroup_id){
$other_info.="杯型:<span class='order_single_text'>".$bx."</span><br>";
$str_other_info.="\"bx\":\"".$bx."\",";
}else{
$str_other_info.="\"bx\":\"\",";
}
$str_other_info.="\"is_gg\":\"".$is_gg."\",";
if($is_gg=="y"){
$other_info.=d_translate("gg")."<span class='order_single_text'>".get_gg_title($bx)."</span><br>";
$tmp=get_db_msg("select * from ".$table_pre."kh_gg where iid='".$msg["id"]."' and color='".$color."' and gg='".$bx."'");
$strgg="";
foreach($sys_gg_zd as $k1 => $v1){
$other_info.=$v1."<span class='order_single_text'>".$tmp[$k1]."</span><br>";
$strgg.="{\"title\":\"".$tmp[$k1]."\"},";
}
$strgg=substr($strgg,0,-1);
$str_other_info.="\"gg\":[".$strgg."],";
}else if($is_gg=="b"){
$other_info.=d_translate("gg")."<span class='order_single_text'>".get_gg_title($bx)."</span><br>";
$str_other_info.="\"gg\":\"".get_gg_title($bx)."\",";
}
$str_other_info=substr($str_other_info,0,-1);
$str_other_info.="}";
$json_data.="\"other_info\":[".$str_other_info."],";
$other_info.="</td></tr></table>";
}
//include template("order_single_qj");
break;
case "single_qj":
$is_brand=is_brand();
$id=$khid;
$have_md="n";
$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);
}else{
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
}
/*if($search_type=="xh"){
if($s_xh){
if($xh_ms=="2"){
//序号到色
$msg_kh_xh=get_db_msg("select * from ".$table_pre."kh_xh where xh='".$s_xh."' limit 0,1");
$q1="select count(*) 'num' from ".$table_pre."kh_xh where xh='".$s_xh."'";
$q2="select a.xh 'xh',b.no 'no',b.id 'id' from ".$table_pre."kh_xh a,".$table_pre."kh b where a.kh=b.no and a.xh='".$s_xh."'";
$msg=get_db_msg("select * from ".$table_pre."kh where no='".$msg_kh_xh["kh"]."' limit 0,1");
}else{
//序号查询定制
$msg=get_db_msg("select * from ".$table_pre."kh where xh='".$s_xh."' limit 0,1");
$q1="select count(*) 'num' from ".$table_pre."kh where xh='".$s_xh."'";
$q2="select xh,no,id from ".$table_pre."kh where xh='".$s_xh."'";
}
$_xh=$s_xh;
$m1=get_db_msg($q1);
}else{
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
$_xh=get_kh_xh($msg);
}
}else{
$s_no=trim($s_no);
if($s_no){
$msg=get_db_msg("select * from ".$table_pre."kh where no like '%".$s_no."%' limit 0,1");
$m1=get_db_msg("select count(*) 'num' from ".$table_pre."kh where no like '%".$s_no."%'");
if($xh_ms=="2")
$q2="select a.xh 'xh',b.no 'no',b.id 'id' from ".$table_pre."kh_xh a,".$table_pre."kh b where a.kh=b.no and b.no like '%".$s_no."%'";
else
$q2="select xh,no,id from ".$table_pre."kh where no like '%".$s_no."%'";
}else{
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
}
$_xh=get_kh_xh($msg);
}*/
$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,";
$_xh=get_kh_xh($msg);
//-------------------设置禁止提交表单
if($order_close=="y" || $msg["ka"]=="y"){
$disable=" disabled";
}else{
$disable="";
}
$json_data.="\"disable\":\"".$disable."\",";
//取得评级
$msg_pj=get_db_msg("select * from ".$table_pre."client_pj where khid='".$id."' and cid='".$uid."'");
if($msg_pj["id"]>0){
$pj_remark=dhtmlchars($msg_pj["remark"]);
$race=$msg_pj["race"];
}else{
$pj_remark="";
$race=0;
}
$q="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and flag_bd='n' and no<>'jgd' and no<>'sx' and no<>'color' order by ord";
$r=$db->query($q);
$i=0;
$zds="";
while($m=$db->fetch_array($r)){
$str_select_dz.="\"".$m["title"]."|";
if($m["no"]=="zd1" || $m["no"]=="zd2" || $m["no"]=="zd3"){
//$str_select_dz.=$msg[$m["no"]]."\",";
//$zds.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
}else{
//$str_select_dz.=deel_js_var(get_cate_title_no($m["no"],$msg[$m["no"]]))."\",";
$zds.="{\"no\":\"".$i."\",\"title\":\"".get_cate_title_no("arr_select",$m["no"])."\",\"value\":\"".get_cate_title_no($m["no"],$msg[$m["no"]])."\"},";
}
$i++;
}
$zds=deel_end($zds);
$json_data.="\"zds\":[".$zds."],";
$json_data.="\"khid\":\"".$msg["id"]."\",";
$json_data.="\"kh\":\"".$msg["no"]."\",";
$json_data.="\"ka\":\"".$msg["ka"]."\",";
$json_data.="\"xh\":\"".get_kh_xh($msg)."\",";
if($msg["size_group"]==$child_sizegroup_id){
//童装尺码异价
foreach($arr_child_bx as $bx1 => $size1){
$m1=get_db_msg("select id,price from ".$table_pre."size_bx where no='".$msg["no"]."' and bx='".$bx1."'");
if($m1["id"]>0){
$price_zk=get_price_zk($uid,$msg["id"],'',$bx1);
$str_price.=$bx1.": ".$m1["price"]."";
if($price_zk!=$m1["price"])
$str_price.=" / 结算价:".$price_zk."";
$str_price.="<br>";
}
}
}else{
$dp_price=get_price_dp($uid,$msg["id"]);
$str_price=deel_num($dp_price)."";
$price_zk=get_price_zk($uid,$msg["id"]);
if($price_zk!=$dp_price){
$str_price.=" / 结算价:".deel_num($price_zk)."";
}
//买断价
$tmp=get_db_msg("select id,price from ".$table_pre."kh_md where (dj='".$msg_login["dj"]."' or dj='') and kh='".$msg["no"]."' limit 0,1");
if($tmp["id"]>0){
$price_md=$tmp["price"]>0?$tmp["price"]:$price_zk;
$str_price.=" / ".d_translate("md")."价:".deel_num($price_md)."";
}
}
$json_data.="\"price\":\"".$str_price."\",";
//$json_data.="\"price\":\"".$msg["price"]."\",";
$json_data.="\"xj\":\"".$race."\",";
$json_data.="\"ksm\":\"".$msg["title"]."\",";
$json_data.="\"pjwz\":\"".$pj_remark."\",";
$pj_icon=get_pj_icon($race,$id,'big');
$is_ggk=is_ggk($msg["id"]);
$json_data.="\"is_ggk\":\"".$is_ggk."\",";
$json_data.="\"size_group_id\":\"".$msg["size_group"]."\",";
if(is_array($sys_color_zd) && count($sys_color_zd)>0){
//取得款色表的定制字段
$str_ds_h=$str_ds_b="";
$str_ds_h="{\"v\":\"颜色\"},";
//$other_info.="<table border=0 cellspacing=1 cellpadding=3 bgcolor='#cccccc'><tr bgcolor='#f0f0f0'><td>颜色</td>";
foreach($sys_color_zd as $k1 => $v1){
//$other_info.="<td>".$v1."</td>";
$str_ds_h.="{\"v\":\"".$v1."\"},";
}
$json_data.="\"ds_header\":[".deel_end($str_ds_h)."],";
//$other_info.="</tr>";
$q="select * from ".$table_pre."kh_color where iid='".$msg["id"]."' order by color";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$str_ds_b.="{\"color\":\"".$m["color"]."\",";
$tmpds="";
$tmpds.="{\"v\":\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\"},";
//$other_info.="<tr bgcolor='#ffffff'><td>".$m["color"]."-".get_cate_title_no("color",$m["color"])."</td>";
foreach($sys_color_zd as $k1 => $v1){
//$other_info.="<td align='center'>".$m[$k1]."</td>";
$tmpds.="{\"v\":\"".$m[$k1]."\"},";
}
//$other_info.="</tr>";
$str_ds_b.="\"v\":[".deel_end($tmpds)."]},";
}
$json_data.="\"ds_body\":[".deel_end($str_ds_b)."],";
//$other_info.="</table>";
}
$arrBx=array();
$str_bx="";
if($msg["size_group"]==$bx_sizegroup_id){
//取得杯型
$r1=$db->query("select * from ".$table_pre."size_bx where no='".$msg["no"]."' order by bx");
$i1=0;
while($m1=$db->fetch_array($r1)){
$arrBx[$i1][]=$m1["bx"];
$str_bx.=$m1["bx"];
$arrBx[$i1][]=$m1["size"];
$i1++;
}
//取得尺码
$str_size="";
$r1=$db->query("select * from ".$table_pre."size where iid='".$bx_sizegroup_id."' order by no");
while($m1=$db->fetch_array($r1)){
$str_size.=$m1["no"].",";
}
$str_size=substr($str_size,0,-1);
$arr_size=explode(",",$str_size);
}else if($msg["size_group"]==$child_sizegroup_id){
//童装
$str_size=$str_bx=$str_bx_title=$str_size_tz="";
$i1=0;
foreach($arr_child_bx as $bx1 => $arr_bx_size1){
$check_tmp=get_db_msg("select id,size,price from ".$table_pre."size_bx where no='".$msg["no"]."' and bx='".$bx1."'");
if($check_tmp["id"]>0){
$str_size_tz.=$i1."|".$check_tmp["size"].":";
$str_bx_title.=$bx1.",";
$str_bx.=$i1.",";
$arrBx[$i1][0]=$i1;
$arrBx[$i1][1]=$check_tmp["size"];
$i1++;
}
}
//取得尺码
$str_size="";
$r1=$db->query("select * from ".$table_pre."size where iid='".$child_sizegroup_id."' order by no");
while($m1=$db->fetch_array($r1)){
$str_size.=$m1["no"].",";
}
$str_size=substr($str_size,0,-1);
$arr_size=explode(",",$str_size);
}else{
if($is_ggk!="n"){
$str_bx.=",";
$r1=$db->query("select gg from ".$table_pre."kh_gg where iid='".$msg["id"]."' group by gg order by gg");
$i1=0;
while($m1=$db->fetch_array($r1)){
$str_bx.=$m1["gg"].",";
$i1++;
}
}
$arrBx[0][0]="";
$arrBx[0][1]=$msg["size"];
$arr_size=explode(",",$msg["size"]);
}
if($str_bx)
$str_bx=substr($str_bx,0,-1);
if($str_bx_title)
$str_bx_title=substr($str_bx_title,0,-1);
if($str_size_tz)
$str_size_tz=substr($str_size_tz,0,-1);
$arr_color=explode(",",$msg["color"]);
$arr_color_ka=explode(",",$msg["color_ka"]);
$total=0;
$js_check_str="";
//取得客户查询条件
$con_uid="";
for($i=0;$i<count($arr_upath);$i++){
$tmp_uid=get_parent_id($arr_upath[$i]);
$m=get_db_msg("select * from ".$table_pre."client where id='".$tmp_uid."'");
if($m["face"]=="4")
$con_uid.="uid='".$m["id"]."' or ";
}
if($con_uid)
$con_uid=" (".substr($con_uid,0,-4).") and ";
else
$con_uid=" uid=0 and ";
//取得数量
$str_num="";
$input_width=get_input_width(count($arr_size));
$json_data.="\"input_width\":\"".$input_width."\",";
//------------------------------------------------------
$num_arr="";
for($i=0;$i<count($arr_color);$i++){
$strarr="";
//判断是否为有规则搭配
$check=get_db_msg("select zsh from ".$table_pre."kh_dp where kh='".$msg["no"]."' and color='".$arr_color[$i]."' and gz<>''");
$colorka="n";
if(in_array($arr_color[$i],$arr_color_ka,true)){
$disable_color=" disabled";
$sty1="font-weight:bold;color:#ff0000;";
$link_ds="";
$colorka="y";
}else if($check["zsh"]>0){
$disable_color=" disabled";
$sty1="";
//$link_ds=" <a href='?_m=dp_single&zsh=".$check["zsh"]."&rurl=".urlencode($this_url)."'><span style='color:#0000ff;'>进入搭配订货</span></a>";
$link_ds=$check["zsh"];
}else{
$sty1="";
$disable_color=$disable;
$link_ds="";
}
$tr_bg=($color==$arr_color[$i])?"#d3d2d1":"#ffffff";
if($is_ggk!="n"){
//有规格
$r1=$db->query("select * from ".$table_pre."kh_gg where iid='".$msg["id"]."' and color='".$arr_color[$i]."' order by ord");
$i1=0;
$arr_gg=array();
while($m1=$db->fetch_array($r1)){
$arr_gg[$i1]["title"]=$m1["gg"];
if($is_ggk=="y"){
foreach($sys_gg_zd as $k1 => $v1){
$arr_gg[$i1][$k1]=$m1[$k1];
}
}
$i1++;
}
$num_arr.="{\"tr_bg\":\"".$tr_bg."\",\"ggs\":\"".count($arr_gg)."\",\"ka\":\"".$colorka."\",\"link_ds\":\"".$link_ds."\",\"sty1\":\"".$sty1."\",\"disable_color\":\"".$disable_color."\",";
$strarr.="{\"no\":\"1\",\"value\":\"".$arr_color[$i]."-".get_cate_title_no("color",$arr_color[$i])."\"},";
$str_num.="<tr><td bgcolor=\"".$tr_bg."\" rowspan=\"".count($arr_gg)."\" id=\"color_td_".$arr_color[$i]."\"><span style=\"".$sty1."\">".$arr_color[$i]."-".get_cate_title_no("color",$arr_color[$i])."</span></td>";
if($i1==0){
$arr_gg[0]["title"]="";
if($is_ggk=="y"){
foreach($sys_gg_zd as $k1 => $v1){
$arr_gg[0][$k1]="";
}
}
}
for($j1=0;$j1<count($arr_gg);$j1++){
$strarr1="";
$s_xj=0;
if($j1>0)
$num_arr.="{\"tr_bg\":\"".$tr_bg."\",\"ggs\":\"1\",\"link_ds\":\"\",\"sty1\":\"".$sty1."\",\"disable_color\":\"".$disable_color."\",";
//$str_num.="<tr bgcolor=\"".$tr_bg."\">";
$strarr1.="{\"no\":\"1\",\"value\":\"".get_gg_title($arr_gg[$j1]["title"])."\"},";
//$str_num.="<td align=\"center\">".get_gg_title($arr_gg[$j1]["title"])."</td>";
if($is_ggk=="y"){
foreach($sys_gg_zd as $k1 => $v1){
//$str_num.="<td align=\"center\">".$arr_gg[$j1][$k1]."</td>";
$strarr1.="{\"no\":\"1\",\"value\":\"".$arr_gg[$j1][$k1]."\"},";
}
}
if($show_gg_zxs=="y")
$strarr1.="{\"no\":\"1\",\"value\":\"".get_main_value1($arr_dhbs,$arr_gg[$j1]["title"])."\"},";
$j=0;
$tmp_msg=get_db_msg("select ".get_size_sql("sum1")." from ".$table_pre."order where ".$con_uid." iid='".$msg["id"]."' and color='".$arr_color[$i]."' and bx='".$arr_gg[$j1]["title"]."' and _key='".$_key."'");
for($k=0;$k<count($arr_size);$k++){
$num1=$tmp_msg["num_".$arr_size[$k]];
$js_check_str.=$num1.",";
if(check_md($msg["no"],$arr_color[$i],$arr_gg[$j1]["title"],$arr_size[$k],$msg_login["dj"])=="n"){
$bg_input_num="#ffffff";
}else{
$bg_input_num="#00ff00";
$have_md="y";
}
if(check_size_not($msg["no"],$arr_color[$i],$arr_gg[$j1]["title"],$arr_size[$k])=="y"){
$disable_color1=" disabled";
$bg_input_num1="#cccccc";
}else{
$disable_color1=$disable_color;
$bg_input_num1=$bg_input_num;
}
$arr_size_check=$arr_size;
if(in_array($arr_size[$k],$arr_size_check)){
$str_num.="<td align=\"right\" style=\"background-color:".$bg_input_num.";\">".$num1."</td>";
$strarr1.="{\"no\":\"3\",\"id\":\"num_".$arr_color[$i]."_".$arr_gg[$j1]["title"]."_".$arr_size[$k]."\",\"value\":".deel_num($num1).",\"bg\":\"".$bg_input_num1."\",\"disable\":\"".$disable_color1."\"},";
}else{
$str_num.="<td bgcolor=\"#ffffff\">&nbsp;</td>";
$strarr1.="{\"no\":\"1\",\"value\":\"&nbsp;\"},";
}
//合计尺码数量
$var_xj_size="xj_size_".$arr_size[$k];
//if($disable_color1==""){
$s_xj+=$num1;
$$var_xj_size+=$num1;
//}
$j++;
}
$total+=$s_xj;
$strarr1.="{\"no\":\"4\",\"id\":\"xj_".$arr_color[$i]."_".$arr_gg[$j1]["title"]."\",\"value\":\"".$s_xj."\"},";
$strarr1.="{\"no\":\"100\",\"khid\":\"".$msg["id"]."\",\"color\":\"".$arr_color[$i]."\",\"bx\":\"".$arr_gg[$j1]["title"]."\"},";
//$strarr=substr($strarr,0,-1);
$num_arr.="\"dt\":[".deel_end($strarr.$strarr1)."]},";
}
}else{
//无规格
//$str_num.="<tr><td bgcolor=\"".$tr_bg."\" rowspan=\"".count($arrBx)."\" id=\"color_td_".$arr_color[$i]."\"><span style=\"".$sty1."\">".$arr_color[$i]."-".get_cate_title_no("color",$arr_color[$i])."</span></td>";
$num_arr.="{\"tr_bg\":\"".$tr_bg."\",\"ggs\":\"".count($arrBx)."\",\"ka\":\"".$colorka."\",\"link_ds\":\"".$link_ds."\",\"sty1\":\"".$sty1."\",";
$strarr.="{\"no\":\"1\",\"value\":\"".$arr_color[$i]."-".get_cate_title_no("color",$arr_color[$i])."\"},";
for($j1=0;$j1<count($arrBx);$j1++){
$strarr1="";
$s_xj=0;
if($j1>0)
$num_arr.="{\"tr_bg\":\"".$tr_bg."\",\"ggs\":\"1\",\"link_ds\":\"\",\"sty1\":\"".$sty1."\",";
if($msg["size_group"]==$bx_sizegroup_id)
$strarr1.="{\"no\":\"1\",\"value\":\"".$arrBx[$j1][0]."\"},";
else if($msg["size_group"]==$child_sizegroup_id)
$strarr1.="{\"no\":\"1\",\"value\":\"".$bx_title."\"},";
$j=0;
$tmp_msg=get_db_msg("select ".get_size_sql("sum1")." from ".$table_pre."order where ".$con_uid." iid='".$msg["id"]."' and color='".$arr_color[$i]."' and bx='".$arrBx[$j1][0]."' and _key='".$_key."'");
$stra="select ".get_size_sql("sum1")." from ".$table_pre."order where ".$con_uid." iid='".$msg["id"]."' and color='".$arr_color[$i]."' and bx='".$arrBx[$j1][0]."' and _key='".$_key."'";
for($k=0;$k<count($arr_size);$k++){
$num1=$tmp_msg["num_".$arr_size[$k]];
$js_check_str.=$num1.",";
if(check_md($msg["no"],$arr_color[$i],$arrBx[$j1][0],$arr_size[$k],$msg_login["dj"])=="n"){
$bg_input_num="#ffffff";
}else{
$bg_input_num="#00ff00";
$have_md="y";
}
if(check_size_not($msg["no"],$arr_color[$i],$arrBx[$j1][0],$arr_size[$k])=="y"){
$disable_color1=" disabled";
$bg_input_num1="#cccccc";
}else{
$disable_color1=$disable_color;
$bg_input_num1=$bg_input_num;
}
if($msg["size_group"]==$bx_sizegroup_id){
$arr_size_check=explode(",",$arrBx[$j1][1]);
}else{
$arr_size_check=$arr_size;
}
if(in_array($arr_size[$k],$arr_size_check)){
//$str_num.="<td align=\"right\" style=\"background-color:".$bg_input_num.";\">".$num1."</td>";
$strarr1.="{\"no\":\"3\",\"id\":\"num_".$arr_color[$i]."_".$tmp_bx."_".$arr_size[$k]."\",\"value\":".deel_num($num1).",\"bg\":\"".$bg_input_num1."\",\"disable\":\"".$disable_color1."\"},";
}else{
//$str_num.="<td bgcolor=\"#ffffff\">&nbsp;</td>";
$strarr1.="{\"no\":\"1\",\"value\":\"&nbsp;\"},";
}
//合计尺码数量
$var_xj_size="xj_size_".$arr_size[$k];
//if($disable_color1==""){
$s_xj+=$num1;
$$var_xj_size+=$num1;
//}
$j++;
}
$total+=$s_xj;
$strarr1.="{\"no\":\"4\",\"id\":\"xj_".$arr_color[$i]."_".$tmp_bx."\",\"value\":\"".$s_xj."\"},";
$strarr1.="{\"no\":\"100\",\"khid\":\"".$msg["id"]."\",\"color\":\"".$arr_color[$i]."\",\"bx\":\"".$arrBx[$j1][0]."\"},";
//$strarr=substr($strarr,0,-1);
$num_arr.="\"dt\":[".deel_end($strarr.$strarr1)."]},";
}
}
//if($j1==0)
//$num_arr.="},";
}
$json_data.="\"stra\":\"".$stra."\",";
$num_arr=substr($num_arr,0,-1);
$json_data.="\"dds\":[".$num_arr."],";
//----------------数量表
//表头
$str_size_title=$cmz="";
for($i=0;$i<count($arr_size);$i++){
$tmp=get_db_msg("select title from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$arr_size[$i]."'");
$str_size_title.=$arr_size[$i]."|".$tmp["title"].",";
$cmz.="{\"no\":\"".$arr_size[$i]."\",\"title\":\"".$tmp["title"]."\"},";
}
if($str_size_title)
$str_size_title=substr($str_size_title,0,-1);
$json_data.="\"str_size_title\":\"".$str_size_title."\",";
$cmz=deel_end($cmz);
$json_data.="\"cmz\":[".$cmz."],";
$content_num="<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\" bgcolor=\"#cccccc\"><tr><td align=\"center\" bgcolor=\"#f0f0f0\">颜色</td>";
if($msg["size_group"]==$bx_sizegroup_id)
$content_num.="<td align=\"center\" bgcolor=\"#f0f0f0\">杯型</td>";
else if($msg["size_group"]==$child_sizegroup_id)
$content_num.="<td align=\"center\" bgcolor=\"#f0f0f0\">款型</td>";
$json_data.="\"gg_t\":\"".d_translate("gg")."\",";
if($is_ggk=="y"){
$content_num.="<td align=\"center\" bgcolor=\"#f0f0f0\">".d_translate("gg")."</td>";
$str_gg_bt="";
foreach($sys_gg_zd as $k1 => $v1){
$content_num.="<td align=\"center\" bgcolor=\"#f0f0f0\">".$v1."</td>";
$str_gg_bt.="{\"gg_zd\":\"".$v1."\"},";
}
$str_gg_bt=substr($str_gg_bt,0,-1);
$json_data.="\"arr_gg_bt\":[".$str_gg_bt."],";
}else if($is_ggk=="b"){
$content_num.="<td align=\"center\" bgcolor=\"#f0f0f0\">".d_translate("gg")."</td>";
}
//
$str_size_t="";
for($i=0;$i<count($arr_size);$i++){
$tmp=get_db_msg("select title from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$arr_size[$i]."'");
$content_num.="<td align=\"center\" bgcolor=\"#f0f0f0\" width=\"50\">".$tmp["title"]."</td>";
$str_size_t.="{\"title\":\"".$tmp["title"]."\",\"no\":\"".$arr_size[$i]."\"},";
}
$str_size_t=substr($str_size_t,0,-1);
$json_data.="\"arr_size\":[".$str_size_t."],";
$content_num.="<td align=\"center\" bgcolor=\"#f0f0f0\" width=\"50\">小计</td><td align=\"center\" bgcolor=\"#f0f0f0\">&nbsp;</td></tr>";
//内容
$content_num.=$str_num;
//合计
$content_num.="<tr><td align=\"right\" bgcolor=\"#f0f0f0\"";
$colspan1=1;
if($msg["size_group"]==$bx_sizegroup_id || $is_ggk=="b" || $msg["size_group"]==$child_sizegroup_id)
$colspan1++;
if($is_ggk=="y")
$colspan1+=count($sys_gg_zd)+1;
$json_data.="\"colspan1\":\"".$colspan1."\",";
$content_num.=" colspan=\"".$colspan1."\">合计</td>";
$str_hj="";
for($i=0;$i<count($arr_size);$i++){
$var_xj_size="xj_size_".$arr_size[$i];
$content_num.="<td align=\"center\" bgcolor=\"#f0f0f0\"><div id=\"xj_size_".$arr_size[$i]."\" align=\"right\" />".$$var_xj_size."</div></td>";
$str_hj.="{\"hj_num\":\"".$$var_xj_size."\"},";
}
$str_hj=substr($str_hj,0,-1);
$json_data.="\"size_hj\":[".$str_hj."],";
$json_data.="\"total\":\"".$total."\",";
$content_num.="<td bgcolor=\"#f0f0f0\" align=\"center\"><div id=\"total\" align=\"right\" />".$total."</div></td><td align=\"center\" bgcolor=\"#f0f0f0\">&nbsp;</td></tr></table>";
if($js_check_str)
$js_check_str=substr($js_check_str,0,-1);
$json_data.="\"js_check_str\":\"".$js_check_str."\",";
//定义图片目录
$pathdir="../attachments/design/mini";
if($flag_pad=="_pad"){
$s_pathdir_mini="content://com.muchuang.edt/attachments/design/mini";
$s_pathdir_big="content://com.muchuang.edt/attachments/design/big";
}else{
$s_pathdir_mini="../attachments/design/mini";
$s_pathdir_big="../attachments/design/big";
}
$json_data.="\"s_pathdir_mini\":\"".$s_pathdir_mini."\",";
$json_data.="\"s_pathdir_big\":\"".$s_pathdir_big."\",";
//--取得单款图片数组
$arr_pic="";
if($sys_close_image=="y"){
$pic_m1="images/no_pic.png";
$pic_b1="images/no_pic_big.png";
//$arr_pic.="\"|".$pic_m1."||".$pic_b1."|\",";
$arr_pic.="{\"color\":\"\",\"pic\":\"".$pic_m1."\",\"pic_w\":0,\"pic_h\":0,\"pic_big\":\"".$pic_b1."\",\"pic_big_w\":0,\"pic_big_h\":0},";
}else{
if(is_file($pathdir."/".$msg["no"].".jpg")){
$pic_m1=$s_pathdir_mini."/".$msg["no"].".jpg";
$pic_b1=$s_pathdir_big."/".$msg["no"].".jpg";
//$arr_pic.="\"|".$pic_m1."|".str_replace("\"",",",out_good_pic_set($pic_m1,30,30))."|".$pic_b1."|".str_replace("\"",",",out_good_pic_set($pic_b1,$tmpl_order_single_w,$tmpl_order_single_h))."\",";
$tmpm=out_good_pic_set_arr($pic_m1,30,30);
$tmpb=out_good_pic_set_arr($pic_b1,$tmpl_order_single_w,$tmpl_order_single_h);
$arr_pic.="{\"color\":\"".$arr_color[$i]."\",\"pic\":\"".$pic_m1."\",\"pic_w\":".$tmpm[0].",\"pic_h\":".$tmpm[1].",\"pic_big\":\"".$pic_b1."\",\"pic_big_w\":".$tmpb[0].",\"pic_big_h\":".$tmpb[1]."},";
}
for($i=0;$i<count($arr_color);$i++){
if(is_file($pathdir."/".$msg["no"]."_".$arr_color[$i].".jpg")){
$pic_m1=$s_pathdir_mini."/".$msg["no"]."_".$arr_color[$i].".jpg";
$pic_b1=$s_pathdir_big."/".$msg["no"]."_".$arr_color[$i].".jpg";
//$arr_pic.="\"".$arr_color[$i]."|".$pic_m1."|".str_replace("\"",",",out_good_pic_set($pic_m1,40,40))."|".$pic_b1."|".str_replace("\"",",",out_good_pic_set($pic_b1,$tmpl_order_single_w,$tmpl_order_single_h))."\",";
$tmpm=out_good_pic_set_arr($pic_m1,40,40);
$tmpb=out_good_pic_set_arr($pic_b1,$tmpl_order_single_w,$tmpl_order_single_h);
$arr_pic.="{\"color\":\"".$arr_color[$i]."\",\"pic\":\"".$pic_m1."\",\"pic_w\":".$tmpm[0].",\"pic_h\":".$tmpm[1].",\"pic_big\":\"".$pic_b1."\",\"pic_big_w\":".$tmpb[0].",\"pic_big_h\":".$tmpb[1]."},";
}
}
}
$arr_pic=substr($arr_pic,0,-1);
$json_data.="\"pics\":[".$arr_pic."],";
//--取得产品细节图
$arr_detail="";
if(check_table_exist($table_pre."pic_detail")=="y"){
$q1="select pic from ".$table_pre."pic_detail where kh='".$msg["no"]."' order by pic";
$r1=$db->query($q1);
while($m1=$db->fetch_array($r1)){
$f=$s_pathdir_mini."/".$m1["pic"];
$f1=$s_pathdir_big."/".$m1["pic"];
$tmpwh=out_good_pic_set_arr($pathdir."/".$m1["pic"],120,120);
$arr_detail.="{\"pic\":\"".$f1."\",\"pic_big\":\"".$f."\",\"pic_w\":".$tmpwh[0].",\"pic_h\":".$tmpwh[1]."},";
$i++;
}
}
$arr_detail=substr($arr_detail,0,-1);
$json_data.="\"xjs\":[".$arr_detail."],";
//--搭配款
$arr_dpk="";
$no_str=trim($msg["dpk"]);
if($no_str){
$arr1=explode(",",$no_str);
for($i=0;$i<count($arr1);$i++){
if($arr1[$i]!=$msg["no"]){
$m1=get_db_msg("select id,no,xh,main_pic,color from ".$table_pre."kh where no='".$arr1[$i]."' limit 0,1");
if($m1["id"]>0){
$con_xh=$s_xh?"&s_xh=".$m1["xh"]:"";
$pic=get_kh_picture($m1["no"],$m1["main_pic"],$m1["color"],$flag_pad_offline);
$t=get_kh_xh($m1)."#".$m1["no"];
$tmpwh=out_good_pic_set_arr($pic,90,120);
$arr_detail.="{\"khid\":\"".$m1["id"]."\",\"pic\":\"".$pic."\",\"pic_w\":".$tmpwh[0].",\"pic_h\":".$tmpwh[1].",\"title\":\"".$t."\"},";
$j++;
}
}
}
}
$arr_dpk=substr($arr_dpk,0,-1);
$json_data.="\"dpks\":[".$arr_dpk."],";
//--取得相关搭配
$arr_dp="";
$q1="select zsh,title,pic from ".$table_pre."kh_dp where kh='".$msg["no"]."' group by zsh order by zsh";
$r1=$db->query($q1);
$i=0;
while($m1=$db->fetch_array($r1)){
$pic=get_kh_dp_mini($m1["pic"],$flag_pad_offline);
$url="?_m=dp_single_qj&zsh=".$m1["zsh"]."&rurl=".urlencode($this_url);
$tmpwh=out_good_pic_set_arr($pic,90,120);
$arr_dp.="{\"zsh\":\"".$m1["zsh"]."\",\"pic\":\"".$pic."\",\"pic_w\":".$tmpwh[0].",\"pic_h\":".$tmpwh[1].",\"title\":\"".$m1["title"]."\"},";
$i++;
}
$arr_dp=substr($arr_dp,0,-1);
$json_data.="\"dps\":[".$arr_dp."],";
//--取得相关陈列
$q="select * from ".$table_pre."kh_cl where kh='".$msg["no"]."' group by zsh";
$r=$db->query($q);
$arr_cl="";
while($m=$db->fetch_array($r)){
$p_big=get_kh_cl_big($m["pic"],$flag_pad_offline);
$url="?_m=cl_single_qj&s_zsh=".$m["zsh"]."&rurl_cl_list=".urlencode($this_url)."";
$pic=get_kh_cl_mini($m["pic"],$flag_pad_offline);
$tmpwh=out_good_pic_set_arr($pic,150,112);
$arr_cl.="{\"zsh\":\"".$m["zsh"]."\",\"pic\":\"".$pic."\",\"pic_w\":".$tmpwh[0].",\"pic_h\":".$tmpwh[1].",\"title\":\"".$m["title"]."".$m["ord"]."\"},";
}
$arr_cl=substr($arr_cl,0,-1);
$json_data.="\"cls\":[".$arr_cl."],";
//--取得相关橱窗
$q="select * from ".$table_pre."kh_cc where kh='".$msg["no"]."' group by zsh";
$r=$db->query($q);
$arr_cc="";
while($m=$db->fetch_array($r)){
$p_big=get_kh_cc_big($m["pic"],$flag_pad_offline);
$url="?_m=show_pic&pic=".$p_big."";
$pic=get_kh_cc_mini($m["pic"],$flag_pad_offline);
$tmpwh=out_good_pic_set_arr($pic,150,112);
$arr_cl.="{\"zsh\":\"".$m["zsh"]."\",\"pic\":\"".$pic."\",\"pic_w\":".$tmpwh[0].",\"pic_h\":".$tmpwh[1].",\"title\":\"".$m["title"]."\"},";
}
$arr_cc=substr($arr_cc,0,-1);
$json_data.="\"ccs\":[".$arr_cc."],";
if($first_act)
$js_onload=" onload=\"".$first_act."\"";
$json_data.="\"js_onload\":\"".$js_onload."\",";
//上一款、下一款
if($xh_ms=="2"){
$pre_xh=get_db_msg("select b.id 'id' from ".$table_pre."kh_xh a,".$table_pre."kh b where a.kh=b.no and a.xh<'".$_xh."' and a.kh<>'".$msg["no"]."' order by a.xh desc limit 0,1");
$next_xh=get_db_msg("select b.id 'id' from ".$table_pre."kh_xh a,".$table_pre."kh b where a.kh=b.no and a.xh>'".$_xh."' and a.kh<>'".$msg["no"]."' order by a.xh limit 0,1");
}else{
$pre_xh=get_db_msg("select id from ".$table_pre."kh where xh<'".$_xh."' and no<>'".$msg["no"]."' order by xh desc limit 0,1");
$next_xh=get_db_msg("select id from ".$table_pre."kh where xh>'".$_xh."' and no<>'".$msg["no"]."' order by xh limit 0,1");
}
$str_sxk="[\"".$pre_xh["id"]."\",\"".$next_xh["id"]."\"]";
$json_data.="\"prev\":\"".$pre_xh["id"]."\",";
$json_data.="\"next\":\"".$next_xh["id"]."\",";
$str_color=$msg["color"];
$json_data.="\"str_color\":\"".$str_color."\",";
//取得定制选项
$select_dz=array();
$q="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'jgd' and no<>'sx' and no<>'color' order by ord";
$r=$db->query($q);
$i=0;
$str_select_dz="";
while($m=$db->fetch_array($r)){
$select_dz[$i][0]=$m["title"].":";
$str_select_dz.="{\"title\":\"".$m["title"]."\",";
if($m["no"]=="zd1" || $m["no"]=="zd2" || $m["no"]=="zd3"){
$select_dz[$i][1]=$msg[$m["no"]];
$str_select_dz.="\"value\":\"".$msg[$m["no"]]."\"},";
}else{
$select_dz[$i][1]=get_cate_title_no($m["no"],$msg[$m["no"]]);
$str_select_dz.="\"value\":\"".get_cate_title_no($m["no"],$msg[$m["no"]])."\"},";
}
$i++;
}
$str_select_dz=substr($str_select_dz,0,-1);
$json_data.="\"select_dz\":[".$str_select_dz."],";
$json_data.="\"translate_xh\":\"".d_translate("xh")."\",";
$json_data.="\"translate_gg\":\"".d_translate("gg")."\",";
$json_data.="\"translate_dhbs\":\"".d_translate("dhbs")."\",";
$json_data.="\"translate_dpk\":\"".d_translate("dpk")."\",";
$json_data.="\"translate_xgdp\":\"".d_translate("xgdp")."\",";
}
//include_once $path_dz."/dp/order_single.php";
//include template("order_single_qj");
break;
default:
//------------------------列表
//---------------搜索条件
$w2=$tmpl_m1_pic_width;
$h2=$tmpl_m1_pic_height;
$page=$page>0?$page:1;
$limit=$limit>0?$limit:12;
$start=($page-1)*$limit;
$end=$limit;
$sql_con="";
$sql_con1="";
if($s_color){
$s_color_a=explode(",",$s_color);
$s1=$s2=$s3="";
//$sql_con_color1="";
for($i1=0;$i1<count($s_color_a);$i1++){
$s1.="color='".$s_color_a[$i1]."' or ";
$s2.="kc.color='".$s_color_a[$i1]."' or ";
//$sql_con_color1.=" b.color<>'".$s_color_a[$i1]."' or ";
}
$sql_con.=" (".substr($s1,0,-3).") and ";
$sql_con1.=" and (".substr($s2,0,-3).")";
//$sql_con_color1=" or (".substr($sql_con_color1,0,-3).")";
$list_by_color="y";
}
//选项
for($i=0;$i<count($arr_select_no);$i++){
$v="s_".$arr_select_no[$i];
if($$v){
$s1=$s2="";
$tmp_a=explode(",",$$v);
for($i1=0;$i1<count($tmp_a);$i1++){
$s1.=$arr_select_no[$i]."='".$tmp_a[$i1]."' or ";
$s2.="a.".$arr_select_no[$i]."='".$tmp_a[$i1]."' or ";
}
$sql_con.=" (".substr($s1,0,-3).") and ";
$sql_con1.=" and (".substr($s2,0,-3).")";
}
}
//到色选项
foreach($sys_color_zd as $k1 => $v1){
$v="s_color_".$k1;
if($$v){
$s1=$s2="";
$tmp_a=explode(",",$$v);
for($i1=0;$i1<count($tmp_a);$i1++){
$s2.="kc.".$k1."='".$tmp_a[$i1]."' or ";
}
$sql_con1.=" and (".substr($s2,0,-3).")";
$list_by_color="y";
}
}
if($s_ka=="y"){
$sql_con.=" (ka='y' or color_ka<>'') and ";
$sql_con1.=" and (a.ka='y')";
}else{
$sql_con.=" (ka<>'y') and ";
$sql_con1.=" and (a.ka<>'y')";
}
/*if($s_con=="no" && $s_value_no!=""){
$sql_con.=$s_con." like '%".$s_value_no."%' and ";
$sql_con1.=" and a.".$s_con." like '%".$s_value_no."%'";
}*/
if($sql_con)
$sql_con=" where ".substr($sql_con,0,-4);
$kl=strlen($s_keyword);
if($kl<=3 && $s_keyword && is_numeric($s_keyword)){
$sql_con=" where xh='".$s_keyword."'";
$sql_con1=" and a.no like '%".$s_keyword."%'";
for($i=0;$i<count($arr_select_no);$i++){
$v="s_".$arr_select_no[$i];
$$v="";
}
$s_xj="";
$s_is_ordered="";
$offset=0;
}
if($kl>=3){
if(is_numeric($s_keyword)){
$sql_con=" where xh='".$s_keyword."' or no like '%".$s_keyword."%'";
$sql_con1=" and (a.xh='".$s_keyword."' or a.no like '%".$s_keyword."%')";
}else{
$sql_con=" where no like '%".$s_keyword."%'";
$sql_con1=" and a.no like '%".$s_keyword."%'";
}
for($i=0;$i<count($arr_select_no);$i++){
$v="s_".$arr_select_no[$i];
$$v="";
}
$s_xj="";
$s_is_ordered="";
$offset=0;
}
/*if($s_con=="xh" && $s_value_xh!=""){
$sql_con="where xh='".$s_value_xh."'";
for($i=0;$i<count($arr_select_no);$i++){
$v="s_".$arr_select_no[$i];
$$v="";
}
$s_xj="";
$s_is_ordered="";
$offset=0;
}*/
//评价星级的条件定制
$con_pjxj="";
if($s_xj){
if(strpos($s_xj,"y")!==false){
//已评
$con_pjxj=" and c.race>0 ";
}else if(strpos($s_xj,"n")!==false){
//未评
$con_pjxj=" and c.race is NULL ";
}else{
$arr_tmp=explode(",",$s_xj);
for($i1=0;$i1<count($arr_tmp);$i1++){
$con_pjxj.=" c.race='".$arr_tmp[$i1]."' or ";
}
$con_pjxj=" and (".substr($con_pjxj,0,-3).") ";
}
}
//$sql_order=str_replace("!"," desc",$order);
$sql_size1="";
for($s1=1;$s1<=$sys_size_num;$s1++){
$sql_size1.="b.num_".$s1."+";
}
if($sql_size1)
$sql_size1=substr($sql_size1,0,-1);
if($list_by_color=="y"){
//展示到色
if($s_is_ordered=="y"){
if($s_xj){
$query="select count(distinct kc.iid,kc.color) 'total' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on a.id=kc.iid left join ".$table_pre."order o on kc.iid=o.iid and kc.color=o.color ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"o.")." left join ".$table_pre."client_pj c on o.iid=c.khid and c.cid='".$uid."' where o.num>0 and o._key='".$_key."' ".$con_pjxj.$sql_con1;
//echo $query."<br>";
}else{
$query="select count(distinct kc.iid,kc.color) 'total' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on a.id=kc.iid left join ".$table_pre."order o on kc.iid=o.iid and kc.color=o.color ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"o.")." where o.num>0 and o._key='".$_key."'".$sql_con1;
}
}else if($s_is_ordered=="n"){
if($s_xj){
$query="select count(distinct kc.iid,kc.color) 'total' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on a.id=kc.iid left join ".$table_pre."order o on kc.iid=o.iid and kc.color=o.color and ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"o.")." and o._key='".$_key."' left join ".$table_pre."client_pj c on o.iid=c.khid and c.cid='".$uid."' where o.num is NULL ".$con_pjxj.$sql_con1;
}else{
$query="select count(distinct kc.iid,kc.color) 'total' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on a.id=kc.iid left join ".$table_pre."order o on kc.iid=o.iid and kc.color=o.color and o._key='".$_key."' ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"o.")." where o.num is NULL ".$sql_con1;
}
}else{
if($s_xj){
$query="select count(distinct kc.iid,kc.color) 'total' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on a.id=kc.iid left join ".$table_pre."client_pj c on kc.iid=c.khid and c.cid='".$uid."' where kc.id>0".$con_pjxj.$sql_con1;
}else{
$query="select count(distinct kc.iid,kc.color) 'total' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on a.id=kc.iid where kc.id>0".$sql_con1;
}
}
}else{
//展示到款
if($s_is_ordered=="y"){
if($s_xj){
$query="select count(distinct c.khid) 'total' from ".$table_pre."order a left join ".$table_pre."client_pj c on a.iid=c.khid and c.cid='".$uid."' where a.id>0 and a._key='".$_key."'".get_qj_ucon_all_dpid($msg_login["charge_uid"],"a.")."".$con_pjxj.$sql_con1;
}else{
$query="select count(distinct a.iid) 'total' from ".$table_pre."order a where a.id>0 and a._key='".$_key."'".get_qj_ucon_all_dpid($msg_login["charge_uid"],"a.")."".$sql_con1;
}
}else if($s_is_ordered=="n"){
if($s_xj){
$query="select count(*) 'total' from ".$table_pre."kh a left join ".$table_pre."order b on a.id=b.iid and b._key='".$_key."' ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"b.")." left join ".$table_pre."client_pj c on a.id=c.khid and c.cid='".$uid."' where b.num is NULL ".$con_pjxj.$sql_con1;
}else{
$query="select count(*) 'total' from ".$table_pre."kh a left join ".$table_pre."order b on a.id=b.iid and b._key='".$_key."' ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"b.")." where b.num is NULL ".$sql_con1;
}
}else{
if($s_xj){
$query="select count(*) 'total' from ".$table_pre."kh a left join ".$table_pre."client_pj c on a.id=c.khid and c.cid='".$uid."' where a.id>0 ".$con_pjxj.$sql_con1;
}else{
$query="select count(*) 'total' from ".$table_pre."kh ".$sql_con;
}
}
}
//echo $query."<br>";
//$json_data.="\"query\":\"".$query."\",";
$res=$db->query($query);
$msg=$db->fetch_array($res);
$total_num=$msg["total"];
$json_data.="\"list_by_color\":\"".$list_by_color."\",";
if($list_by_color=="y"){
//------------------展示到色
//定制条件
if($s_is_ordered=="y"){
if($s_xj){
$query="select a.*,c.race,b.num,kc.color 'color' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on kc.iid=a.id left join ".$table_pre."order b on kc.iid=b.iid ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"b.")." left join ".$table_pre."client_pj c on kc.iid=c.khid and c.cid='".$uid."' where b.num>0 and b._key='".$_key."'".$con_pjxj.$sql_con1." group by kc.id,kc.color order by a.xh,a.no limit ".$start.",".$end;
}else{
$query="select a.*,b.num,kc.color 'color' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on kc.iid=a.id left join ".$table_pre."order b on kc.iid=b.iid and kc.color=b.color ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"b.")." where b.num>0 and b._key='".$_key."' ".$sql_con1." group by kc.id,kc.color order by a.xh,a.no limit ".$start.",".$end;
}
//echo $query."<br>";
}else if($s_is_ordered=="n"){
if($s_xj){
$query="select a.*,c.race,b.num,kc.color 'color' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on kc.iid=a.id left join ".$table_pre."order b on kc.iid=b.iid and b.color=kc.color and b._key='".$_key."' ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"b.")." left join ".$table_pre."client_pj c on kc.iid=c.khid and c.cid='".$uid."' where b.num is NULL ".$con_pjxj.$sql_con1." group by kc.id,kc.color order by a.xh,a.no limit ".$start.",".$end;
}else{
$query="select a.*,b.num,kc.color 'color' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on kc.iid=a.id left join ".$table_pre."order b on kc.iid=b.iid and b.color=kc.color and b._key='".$_key."' ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"b.")." where b.num is NULL ".$sql_con1." group by kc.id,kc.color order by a.xh,a.no limit ".$start.",".$end;
}
}else{
if($s_xj){
$query="select a.*,c.race,kc.color 'color' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on kc.iid=a.id left join ".$table_pre."client_pj c on kc.iid=c.khid and c.cid='".$uid."' where kc.id>0".$con_pjxj.$sql_con1." group by kc.id,kc.color order by a.xh,a.no limit ".$start.",".$end;
}else{
$query="select a.*,kc.color 'color' from ".$table_pre."kh_color kc left join ".$table_pre."kh a on kc.iid=a.id where kc.id>0".$sql_con1." group by kc.id,kc.color order by a.xh,a.no limit ".$start.",".$end;
}
}
if($xh_ms=="2"){
//-------定制序号查询
if($s_con=="xh" && $s_value_xh!=""){
$query="select a.*,b.xh 'xh' from ".$table_pre."kh a,".$table_pre."kh_xh b where a.no=b.kh and b.xh='".$s_value_xh."'";
}
}
//echo $query."<br>";
//$json_data.="\"query\":\"".$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.="\"s_keyword\":\"".$s_keyword."\",";
$json_data.="\"ka_color\":\"".$ka_color."\",";
$json_data.="\"content_set\":\"".$pic_background."\",";
$json_data.="\"count\":".$total_num.",\"data\":[";
$data_str="";
$content_list="[";
$arr_id=array();
for($count=0;$count<$end;$count++){
$msg=$db->fetch_array($res);
$arr_id[$count]=$msg["id"];
if($msg["ka"]=="y"){
$c=get_set("ka_color");
}else{
$c=get_set_value_dote($style_title_color,$msg["kh_dj"]);
}
if($msg["id"]>0){
//图片获取规则
$pic=get_kh_color_picture($msg["no"],$msg["color"],$flag_pad_offline);
//取得已订件数
//$n1=deel_num(get_order_num_kh_color($msg["id"],$msg["color"]));
$tmp=get_db_msg("select sum(num) 'num' from ".$table_pre."order where ka<>'y' and _key='".$_key."' and iid='".$msg["id"]."' and color='".$msg["color"]."' ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"")."");
$n1=deel_num($tmp["num"]);
//取得颜色数量
$str_c_num=",".$msg["color"]."-".get_cate_title_no("color",$msg["color"]);
//取得上次订货会数量
$str_sys="";
if($sys_flag_count>1){
$tmp_sys=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where _key<>'".$_key."' and iid='".$msg["id"]."' and color='".$msg["color"]."' ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"")."");
if($tmp_sys["num"]){
$str_sys="\"scjs\":".$tmp_sys["num"].",\"hjjs\":".($tmp_sys["num"]+$n1).",";
}
$str_sys.="\"lssj\":\"y\",";
}
//取得评价信息
$tmp=get_db_msg("select id,race,remark from ".$table_pre."client_pj where khid='".$msg["id"]."' and cid='".$uid."'");
$pj_race=$tmp["race"]>0?$tmp["race"]:0;
$pj_id=$tmp["id"]>0?$tmp["id"]:0;
$pj_remark=deel_js_var($tmp["remark"]);
$msg_pj=$pj_id."|".$pj_race."|".deel_js_var($tmp["remark"]);
//取得滑动展示信息
$text_main="";
$q="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'jgd' and no<>'sx' and no<>'color' order by ord";
$r=$db->query($q);
$tmpzd="";
while($m=$db->fetch_array($r)){
if($m["no"]=="zd1" || $m["no"]=="zd2" || $m["no"]=="zd3"){
$tmpzd.=",\"".$m["no"]."\":\"".$msg[$m["no"]]."\"";
$text_main.=$msg[$m["no"]]."";
}else{
$tmpzd.=",\"".$m["no"]."\":\"".deel_js_var(get_cate_title_no($m["no"],$msg[$m["no"]]))."\"";
$text_main.=deel_js_var(get_cate_title_no($m["no"],$msg[$m["no"]]))."";
}
}
if($text_main)
$text_main=substr($text_main,0,-2);
if($msg["remark"]!="")
$text_main.="<br>".deel_js_var(dhtmlchars($msg["remark"]));
if($msg["size_group"]==$child_sizegroup_id){
//童装不显示价格
$this_price=0;
}else{
$this_price=deel_num(get_price_dp($uid,$msg["id"]));
}
//$content_list.="".$msg["id"].",\"".get_kh_xh($msg,$msg["color"])."\",\"".$msg["no"].$str_c_num."\",".$this_price.",\"".$pic."\",\"".str_replace("\"","'",out_good_pic_set($pic,$w2,$h2))."\",".$n1.",\"".$c."\",\"".$msg_pj."\",\"".$text_main."\",";
//
$rnum++;
$ck=out_good_pic_set_arr($pic,$w2,$h2);
$data_str.="{\"id\":".$msg["id"].",\"xh\":\"".get_kh_xh($msg,$msg["color"])."\",\"kh\":\"".$msg["no"]."\",\"color\":\"".$msg["color"]."\",\"color_title\":\"".get_cate_title_no("color",$msg["color"])."\",\"pic\":\"".$pic."\",\"pic_w\":".$ck[0].",\"pic_h\":".$ck[1].",\"ydjs\":".$n1.",\"unit_title\":\"".$msg["unit_title"]."\",".$str_sys."\"price\":".$this_price.",\"xj\":\"".$pj_race."\",\"pj_remark\":\"".$pj_remark."\"".$tmpzd."},";
}
}
$content_list.="]";
}else{
//------------------展示到款
//定制条件
if($s_is_ordered=="y"){
if($s_xj){
$query="select a.*,c.race,b.num from ".$table_pre."kh a left join ".$table_pre."order b on a.id=b.iid ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"b.")." left join ".$table_pre."client_pj c on a.id=c.khid and c.cid='".$uid."' where b.num>0 and b._key='".$_key."'".$con_pjxj.$sql_con1." group by a.id order by a.xh,a.no limit ".$start.",".$end;
}else{
$query="select a.*,b.num from ".$table_pre."kh a left join ".$table_pre."order b on a.id=b.iid ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"b.")." where b.num>0 and b._key='".$_key."' ".$sql_con1." group by a.id order by a.xh,a.no limit ".$start.",".$end;
}
//echo $query."<br>";
}else if($s_is_ordered=="n"){
if($s_xj){
$query="select a.*,c.race,b.num from ".$table_pre."kh a left join ".$table_pre."order b on a.id=b.iid ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"b.")." left join ".$table_pre."client_pj c on a.id=c.khid and c.cid='".$uid."' where b.num is NULL and b._key='".$_key."' ".$con_pjxj.$sql_con1." order by a.xh,a.no limit ".$start.",".$end;
}else{
$query="select a.*,b.num from ".$table_pre."kh a left join ".$table_pre."order b on a.id=b.iid ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"b.")." where (b.num is NULL) and b._key='".$_key."' ".$sql_con1." order by a.xh,a.no limit ".$start.",".$end;
}
}else{
if($s_xj){
$query="select a.*,c.race from ".$table_pre."kh a left join ".$table_pre."client_pj c on a.id=c.khid and c.cid='".$uid."' where a.id>0 ".$con_pjxj.$sql_con1." order by a.xh,a.no limit ".$start.",".$end;
}else{
$query="select * from ".$table_pre."kh ".$sql_con."order by xh,no limit ".$start.",".$end;
}
}
if($xh_ms=="2"){
//-------定制序号查询
if($s_con=="xh" && $s_value_xh!=""){
$query="select a.*,b.xh 'xh' from ".$table_pre."kh a,".$table_pre."kh_xh b where a.no=b.kh and b.xh='".$s_value_xh."'";
}
}
//echo $query."<br>";
//$json_data.="\"query\":\"".$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_num.",\"data\":[";
$data_str="";
$content_list="[";
$arr_id=array();
for($count=0;$count<$end;$count++){
$msg=$db->fetch_array($res);
$arr_id[$count]=$msg["id"];
if($msg["ka"]=="y"){
$c=get_set("ka_color");
}else{
$c=get_set_value_dote($style_title_color,$msg["kh_dj"]);
}
if($msg["id"]>0){
//图片获取规则
$pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"],$flag_pad_offline);
//取得已订件数
//$n1=deel_num(get_order_num_kh($msg["id"]));
$tmp=get_db_msg("select sum(num) 'num' from ".$table_pre."order where ka<>'y' and _key='".$_key."' and iid='".$msg["id"]."' ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"")."");
$n1=deel_num($tmp["num"]);
//取得颜色数量
$c_num=count(explode(",",$msg["color"]));
$str_c_num="";
if($is_dkds!="y"){
$str_c_num=" (".$c_num."色)";
}
//取得上次订货会数量
$str_sys="";
if($sys_flag_count>1){
$tmp_sys=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where _key<>'".$_key."' and iid='".$msg["id"]."' ".get_qj_ucon_all_dpid($msg_login["charge_uid"],"")."");
if($tmp_sys["num"]){
$str_sys="\"scjs\":".$tmp_sys["num"].",\"hjjs\":".($tmp_sys["num"]+$n1).",";
}
$str_sys.="\"lssj\":\"y\",";
}
//取得评价信息
$tmp=get_db_msg("select id,race,remark from ".$table_pre."client_pj where khid='".$msg["id"]."' and cid='".$uid."'");
$pj_race=$tmp["race"]>0?$tmp["race"]:0;
$pj_id=$tmp["id"]>0?$tmp["id"]:0;
$pj_remark=deel_js_var($tmp["remark"]);
$msg_pj=$pj_id."|".$pj_race."|".deel_js_var($tmp["remark"]);
//取得滑动展示信息
$text_main="";
$q="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'jgd' and no<>'sx' and no<>'color' order by ord";
$r=$db->query($q);
$tmpzd="";
while($m=$db->fetch_array($r)){
if($m["no"]=="zd1" || $m["no"]=="zd2" || $m["no"]=="zd3"){
$tmpzd.=",\"".$m["no"]."\":\"".$msg[$m["no"]]."\"";
$text_main.=$msg[$m["no"]]."";
}else{
$tmpzd.=",\"".$m["no"]."\":\"".deel_js_var(get_cate_title_no($m["no"],$msg[$m["no"]]))."\"";
$text_main.=deel_js_var(get_cate_title_no($m["no"],$msg[$m["no"]]))."";
}
}
if($text_main)
$text_main=substr($text_main,0,-2);
if($msg["remark"]!="")
$text_main.="<br>".deel_js_var(dhtmlchars($msg["remark"]));
//$content_list.="".$msg["id"].",\"".get_kh_xh($msg)."\",\"".$msg["no"].$str_c_num."\",".deel_num(get_price_dp($uid,$msg["id"])).",\"".$pic."\",\"".str_replace("\"","'",out_good_pic_set($pic,$w2,$h2))."\",".$n1.",\"".$c."\",\"".$msg_pj."\",\"".$text_main."\",";
//
$rnum++;
$ck=out_good_pic_set_arr($pic,$w2,$h2);
$data_str.="{\"id\":".$msg["id"].",\"xh\":\"".get_kh_xh($msg)."\",\"kh\":\"".$msg["no"]."\",\"color\":\"nocolor\",\"color_title\":\"\",\"pic\":\"".$pic."\",\"pic_w\":".$ck[0].",\"pic_h\":".$ck[1].",\"ydjs\":".$n1.",\"unit_title\":\"".$msg["unit_title"]."\",".$str_sys."\"ka_color\":\"".$c."\",\"price\":".deel_num(get_price_dp($uid,$msg["id"])).",\"xj\":\"".$pj_race."\",\"pj_remark\":\"".$pj_remark."\"".$tmpzd."},";
}
}
$content_list.="]";
}
$json_data.=substr($data_str,0,-1)."],";
//---------------款号数据
//传递参数:s_brand|选项,s_xj|星级,s_is_order|已订,s_is_ka|删除款
//每次加载条数
$page_size=12;
//图片标准188*250
/*$json_data.="\"data\":[";
$json_data.="{\"id\":1,\"xh\":\"1\",\"kh\":\"12W1102\",\"pic\":\"../attachments/design/mini/12W1102.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":4,\"price\":587,\"xj\":4,\"khdj\":\"必订\"},";
$json_data.="{\"id\":2,\"xh\":\"2\",\"kh\":\"12W010251\",\"pic\":\"../attachments/design/mini/12W0102_51.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":897,\"xj\":5,\"khdj\":\"常规\"},";
$json_data.="{\"id\":3,\"xh\":\"3\",\"kh\":\"12W1123\",\"pic\":\"../attachments/design/mini/12W1123_91.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":2,\"price\":865,\"xj\":0,\"khdj\":\"常规\"},";
$json_data.="{\"id\":4,\"xh\":\"4\",\"kh\":\"12W3110\",\"pic\":\"../attachments/design/mini/12W3110_91.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":110,\"price\":759,\"xj\":2,\"khdj\":\"推荐\"},";
$json_data.="{\"id\":5,\"xh\":\"5\",\"kh\":\"12W3128\",\"pic\":\"../attachments/design/mini/12W3128_41.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":1200,\"xj\":1,\"khdj\":\"常规\"},";
$json_data.="{\"id\":6,\"xh\":\"6\",\"kh\":\"12W3127\",\"pic\":\"../attachments/design/mini/12W3127_91.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":600,\"xj\":5,\"khdj\":\"常规\"},";
$json_data.="{\"id\":7,\"xh\":\"7\",\"kh\":\"12W3105\",\"pic\":\"../attachments/design/mini/12W3105_91.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":800,\"xj\":0,\"khdj\":\"\"},";
$json_data.="{\"id\":8,\"xh\":\"8\",\"kh\":\"12W2112\",\"pic\":\"../attachments/design/mini/12W2112_41.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":800,\"xj\":0,\"khdj\":\"\"},";
$json_data.="{\"id\":9,\"xh\":\"9\",\"kh\":\"12W2123\",\"pic\":\"../attachments/design/mini/12W2123_82.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":800,\"xj\":0,\"khdj\":\"\"},";
$json_data.="{\"id\":10,\"xh\":\"10\",\"kh\":\"12W3106\",\"pic\":\"../attachments/design/mini/12W3106_52.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":800,\"xj\":0,\"khdj\":\"\"},";
$json_data.="{\"id\":11,\"xh\":\"11\",\"kh\":\"12W5104\",\"pic\":\"../attachments/design/mini/12W5104_11.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":800,\"xj\":0,\"khdj\":\"\"},";
$json_data.="{\"id\":12,\"xh\":\"12\",\"kh\":\"12W5117\",\"pic\":\"../attachments/design/mini/12W5117_11.jpg\",\"pic_w\":188,\"pic_h\":250,\"ydjs\":0,\"price\":800,\"xj\":0,\"khdj\":\"\"}";
$json_data.="],";*/
//总计条数
$json_data.="\"total_num\":".$total_num.",";
//已经加载条数
//$json_data.="\"show_num\":12,";
$total_page=ceil($total_num/$limit);
$json_data.="\"total_page\":".$total_page.",";
$json_data.="\"page\":".$page.",";
//已经加载条数
//$json_data.="\"show_num\":12,";
//单独下拉字段
$select_dz="";
$arrdd=array();
for($i=0;$i<count($sys_dk_search_cate_single);$i++){
//取得选项
$tmp="";
$r1=$db->query("select no,title from ".$table_pre."keyword where cate='".$sys_dk_search_cate_single[$i]."' order by no");
while($m1=$db->fetch_array($r1)){
$tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
}
$tmp=deel_end($tmp);
$var="s_".$sys_dk_search_cate_single[$i];
$arrdd[]=$var;
$select_dz.="{\"no\":\"".$sys_dk_search_cate_single[$i]."\",\"title\":\"".get_cate_title_no("arr_select",$sys_dk_search_cate_single[$i])."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
$select_dz=deel_end($select_dz);
$json_data.="\"select_single\":[".$select_dz."],";
//更多条件下拉字段
$select_dz="";
for($i=0;$i<count($sys_dk_search_cate);$i++){
$var="s_".$sys_dk_search_cate[$i];
if(!in_array($var,$arrdd)){
if($sys_dk_search_cate[$i]=="color"){
$tmp="";
$r1=$db->query("select no,title from ".$table_pre."keyword where cate='".$sys_dk_search_cate[$i]."' order by no");
while($m1=$db->fetch_array($r1)){
$tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
}
$tmp=deel_end($tmp);
$select_dz.="{\"no\":\"".$sys_dk_search_cate[$i]."\",\"title\":\"颜色\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}elseif(substr($sys_dk_search_cate[$i],0,6)=="color_"){
$tmp_key=str_replace("color_","",$sys_dk_search_cate[$i]);
$tmp="";
$r1=$db->query("select no,title from ".$table_pre."keyword where cate='".$tmp_key."' order by no");
while($m1=$db->fetch_array($r1)){
$tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
}
$tmp=deel_end($tmp);
$select_dz.="{\"no\":\"".$sys_dk_search_cate[$i]."\",\"title\":\"".get_main_value($sys_color_zd,$tmp_key)."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}else{
$tmp="";
$r1=$db->query("select no,title from ".$table_pre."keyword where cate='".$sys_dk_search_cate[$i]."' order by no");
while($m1=$db->fetch_array($r1)){
$tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
}
$tmp=deel_end($tmp);
$select_dz.="{\"no\":\"".$sys_dk_search_cate[$i]."\",\"title\":\"".get_cate_title_no("arr_select",$sys_dk_search_cate[$i])."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
}
}
}
//$json_data.="\"select_more\":[";
//
//$json_data.="{\"no\":\"category\",\"title\":\"大类\",\"value\":\"1,2\",\"op\":[{\"no\":\"1\",\"title\":\"上装\"},{\"no\":\"2\",\"title\":\"下装\"},{\"no\":\"3\",\"title\":\"饰品\"}]},";
//$json_data.="{\"no\":\"bc\",\"title\":\"波段\",\"value\":\"11\",\"op\":[{\"no\":\"11\",\"title\":\"第一波\"},{\"no\":\"12\",\"title\":\"第二波\"}]},";
//星级筛选
$select_dz.="{\"no\":\"xj\",\"title\":\"星级\",\"value\":\"".$s_xj."\",\"op\":[{\"no\":\"1\",\"title\":\"1星\"},{\"no\":\"2\",\"title\":\"2星\"},{\"no\":\"3\",\"title\":\"3星\"},{\"no\":\"4\",\"title\":\"4星\"},{\"no\":\"5\",\"title\":\"5星\"},{\"no\":\"y\",\"title\":\"已评\"},{\"no\":\"n\",\"title\":\"未评\"}]},";
//已订,未订
$select_dz.="{\"no\":\"is_ordered\",\"title\":\"已订未订\",\"value\":\"".$s_is_ordered."\",\"op\":[{\"no\":\"y\",\"title\":\"已订\"},{\"no\":\"n\",\"title\":\"未订\"}]},";
//是否删除款
$select_dz.="{\"no\":\"ka\",\"title\":\"是否删除款\",\"value\":\"".$s_ka."\",\"op\":[{\"no\":\"n\",\"title\":\"非删除款\"},{\"no\":\"y\",\"title\":\"仅删除款\"}]},";
//
$select_dz=deel_end($select_dz);
$json_data.="\"select_more\":[".$select_dz."],";
$json_data.="\"s_keyword\":\"".$s_keyword."\",";
break;
}
}
}
$json_data=substr($json_data,0,-1)."}";
echo $json_data;
?>