0?$tid:0;//$tid来自于浏览器URL$tid
//取得当前展示号
$tmp=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' and is_show='y' order by zsh");
if($tmp["zsh"]>0){
$dq_zsh=$tmp['zsh'];
//大于当前展示号的顺延
$db->query("update ".$table_pre."kh_tb set zsh=zsh+1 where zsh>'".$dq_zsh."' and tid='".$tid."'");
}else{
$tmp=get_db_msg("select MAX(zsh) 'zsh' from ".$table_pre."kh_tb where tid='".$tid."'");
$dq_zsh=$tmp['zsh']?$tmp['zsh']:0;
}
//
$ord=1;
if($s_zsh){
$tmp_dph=get_db_msg("select * from web_kh_dp where zsh='".$s_zsh."' limit 0,1");
$s_dir=$order_session?$order_session."/":"";
$pic="dp/".$s_dir."big/".$tmp_dph["pic"].".jpg";
$sql="insert into ".$table_pre."kh_tb (tid,zsh,pic,iid,color,ord,is_show) values ";
foreach($arr_khno as $khno){
$arr_tmp=explode("|",$khno);
$sql.="(".$tid.",".($dq_zsh+1).",'".$pic."',".$arr_tmp[0].",'".$arr_tmp[1]."',".$ord++.",'y'),";
}
}else{
$sql="insert into ".$table_pre."kh_tb (tid,zsh,iid,color,ord,is_show) values ";
foreach($arr_khno as $khno){
$arr_tmp=explode("|",$khno);
$sql.="(".$tid.",".($dq_zsh+1).",".$arr_tmp[0].",'".$arr_tmp[1]."',".$ord++.",'y'),";
}
}
$sql=substr($sql,0,-1).";";
$json_data.="\"q\":\"".$sql."\",";
$db->query($sql);
if($tid>0){
$db->query("update ".$table_pre."kh_tb set is_show='n' where zsh<>'".($dq_zsh+1)."' and tid='".$tid."'");
}else{
$db->query("update ".$table_pre."kh_tb set is_show='n' where zsh<>'".($dq_zsh+1)."'");
}
$str="y";
$json_data.="\"code\":101,";
break;
case "tb_search":
$w2=$tmpl_m5_pic_width;
$h2=$tmpl_m5_pic_height;
$arr_ksh=explode(",",$wanted_kh);
//默认展厅后新添加自定义推送的单款
$sql="select * from ".$table_pre."kh where no='".$arr_ksh[0]."'";
$str="";
$str_dk="";
$msg=get_db_msg($sql);
if($msg['id']>0){
if($msg["ka"]=="y"){
$c=$ka_color;
}else{
$c=get_set_value_dote($style_title_color,$msg["kh_dj"]);
}
//取得搜索结果的款号图片
if($arr_ksh[1]){
$pic=get_kh_color_picture($msg["no"],$arr_ksh[1]);
}else{
$pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"],$flag_pad_offline);
}
//单款信息拼接
$str.=$msg["id"].",".get_kh_xh($msg).",".$msg["no"].",".$arr_ksh[1].",".$msg["price"].",".$pic.",".str_replace("\"","'",out_good_pic_set($pic,$w2,$h2));
$tmpwh=out_good_pic_set_arr($pic,$w2,$h2);
$str_dk.="{\"khid\":\"".$msg["id"]."\",\"xh\":\"".get_kh_xh($msg)."\",\"kh\":\"".$msg["no"]."\",\"color\":\"".$arr_ksh[1]."\",\"colort\":\"".get_cate_title_no("color",$arr_ksh[1])."\",\"price\":\"".$msg["price"]."\",\"pic\":\"".$pic."\",\"pic_w\":".deel_num($tmpwh[0]).",\"pic_h\":".deel_num($tmpwh[1])."},";
}
$str_dk=substr($str_dk,0,-1);
$json_data.="\"arr_dk\":[".$str_dk."],";
//------------------------------
break;
case "tb_search_dp":
$w2=$tmpl_m5_pic_width;
$h2=$tmpl_m5_pic_height;
if($s_zsh){
$dph=$s_zsh;
}
$arr_ksh=explode(",",$wanted_kh);
//默认展厅后新添加自定义推送的单款
$query="select * from ".$table_pre."kh_dp where zsh='".$dph."'";
//echo $query."
";
$res=$db->query($query);
$str="";
$str_dp="";
$dp_pic="";
while($msg1=$db->fetch_array($res)){
$dp_pic=$msg1["pic"];
$msg=get_db_msg("select * from ".$table_pre."kh where no='".$msg1["kh"]."' ");
if($msg["ka"]=="y"){
$c=$ka_color;
}else{
$c=get_set_value_dote($style_title_color,$msg["kh_dj"]);
}
//取得搜索结果的款号图片
$pic=get_kh_color_picture($msg["no"],$msg1["color"]);
//单款信息拼接
//$str.=$msg["id"].",".get_kh_xh($msg).",".$msg["no"].",".$arr_ksh[1].",".$msg["price"].",".$pic.",".str_replace("\"","'",out_good_pic_set($pic,$w2,$h2));
$tmpwh=out_good_pic_set_arr($pic,$w2,$h2);
$str_dp.="{\"khid\":\"".$msg["id"]."\",\"xh\":\"".get_kh_xh($msg)."\",\"kh\":\"".$msg["no"]."\",\"color\":\"".$msg1["color"]."\",\"colort\":\"".get_cate_title_no("color",$msg1["color"])."\",\"price\":\"".$msg["price"]."\",\"pic\":\"".$pic."\",\"pic_w\":".deel_num($tmpwh[0]).",\"pic_h\":".deel_num($tmpwh[1])."},";
}
$str_dp=substr($str_dp,0,-1);
$json_data.="\"arr_dk\":[".$str_dp."],";
//------------------------------
break;
case "tb_pre":
//设置上一组同步
$tmp=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' and is_show='y' group by zsh order by zsh desc limit 0,1");
if($tmp["zsh"]>0){
$tmp1=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' and zsh<'".$tmp["zsh"]."' group by zsh order by zsh desc limit 0,1");
}else{
$tmp1=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' group by zsh order by zsh limit 0,1");
}
if($tmp1["zsh"]){
$db->query("update ".$table_pre."kh_tb set is_show='y' where tid='".$tid."' and zsh='".$tmp1["zsh"]."'");
$db->query("update ".$table_pre."kh_tb set is_show='n' where tid='".$tid."' and zsh<>'".$tmp1["zsh"]."' and is_show='y'");
$str="y";
$json_data.="\"code\":101,";
}else{
$str="n";
$json_data.="\"code\":0,";
}
break;
case "tb_next":
//设置下一组同步
$tmp=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' and is_show='y' group by zsh order by zsh desc limit 0,1");
if($tmp["zsh"]>0){
$tmp1=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' and zsh>'".$tmp["zsh"]."' group by zsh order by zsh limit 0,1");
}else{
$tmp1=get_db_msg("select zsh from ".$table_pre."kh_tb where tid='".$tid."' group by zsh order by zsh limit 0,1");
}
if($tmp1["zsh"]){
$db->query("update ".$table_pre."kh_tb set is_show='y' where tid='".$tid."' and zsh='".$tmp1["zsh"]."'");
$db->query("update ".$table_pre."kh_tb set is_show='n' where tid='".$tid."' and zsh<>'".$tmp1["zsh"]."' and is_show='y'");
$str="y";
$json_data.="\"code\":101,";
}else{
$str="n";
$json_data.="\"code\":0,";
}
break;
case "tb_zsh":
//设置特定展示号同步
$tmp=get_db_msg("select id from ".$table_pre."kh_tb where tid='".$tid."' and zsh='".$zsh."' limit 0,1");
if($tmp["id"]>0){
$db->query("update ".$table_pre."kh_tb set is_show='y' where tid='".$tid."' and zsh='".$zsh."'");
$db->query("update ".$table_pre."kh_tb set is_show='n' where tid='".$tid."' and zsh<>'".$zsh."' and is_show='y'");
$str="y";
$json_data.="\"code\":101,";
}else{
$str="n";
$json_data.="\"code\":0,";
}
break;
case "del_zsh":
//删除特定展示组
$tmp=get_db_msg("select id from ".$table_pre."kh_tb where tid='".$tid."' and zsh='".$zsh."' limit 0,1");
if($tmp["id"]>0){
$db->query("delete from ".$table_pre."kh_tb where tid='".$tid."' and zsh='".$zsh."'");
$str="y";
$json_data.="\"code\":101,";
}else{
$str="不存在";
$json_data.="\"code\":0,";
$json_data.="\"msg\":\"不存在\",";
}
break;
case "kh_color" :
//
$sql_con="";
if($q){
$sql_con.=" and no like '%".$q."%'";
}
//$json_data.="\"q\":\"".$q."\",";
$query="select * from ".$table_pre."kh where id>0 ".$sql_con." order by no";
//echo $query."
";
$res=$db->query($query);
$count=0;
$data=array();
$str_tmp="";
$i=0;
while($msg=$db->fetch_array($res)){
$color=explode(",",$msg["color"]);
$colork=explode(",",$msg["color_ka"]);
$str_tmp.="{\"id\":\"".$msg["id"]."\",\"no\":\"".$msg["no"]."\",\"xh\":\"".get_kh_xh($msg)."\"},";
foreach($color as $k => $v){
if(!in_array($v,$colork)){
$str_tmp.="{\"id\":\"".$msg["id"]."\",\"no\":\"".$msg["no"]."\",\"xh\":\"".get_kh_xh($msg,$v)."\",\"color\":\"".$v."\",\"colort\":\"".get_cate_title_no("color",$v)."\"},";
}
}
$i++;
}
$json_data.="\"data\":[".deel_end($str_tmp)."],";
break;
case "kh_color1" :
//
$sql_con="";
if($q){
$sql_con.=" and xh='".$q."'";
}
//$json_data.="\"q\":\"".$q."\",";
$query="select * from ".$table_pre."kh where id>0 ".$sql_con." order by no";
//echo $query."
";
$res=$db->query($query);
$count=0;
$data=array();
$str_tmp="";
$i=0;
while($msg=$db->fetch_array($res)){
$color=explode(",",$msg["color"]);
$colork=explode(",",$msg["color_ka"]);
$str_tmp.="{\"id\":\"".$msg["id"]."\",\"no\":\"".$msg["no"]."\",\"xh\":\"".get_kh_xh($msg)."\"},";
foreach($color as $k => $v){
if(!in_array($v,$colork)){
$str_tmp.="{\"id\":\"".$msg["id"]."\",\"no\":\"".$msg["no"]."\",\"xh\":\"".get_kh_xh($msg,$v)."\",\"color\":\"".$v."\",\"colort\":\"".get_cate_title_no("color",$v)."\"},";
}
}
$i++;
}
$json_data.="\"data\":[".deel_end($str_tmp)."],";
break;
case "get_dph" :
//
$sql_con="";
if($q){
$sql_con.=" and zsh like '%".$q."%'";
}
$query="select DISTINCT zsh,title from ".$table_pre."kh_dp where id>0 ".$sql_con." order by zsh";
//echo $query."
";
$res=$db->query($query);
$count=0;
$data=array();
$str_tmp="";
$i=0;
while($msg=$db->fetch_array($res)){
$str_tmp.="{\"zsh\":\"".$msg["zsh"]."\",\"title\":\"".$msg["title"]."\"},";
$i++;
}
$json_data.="\"data\":[".deel_end($str_tmp)."],";
break;
case "pj":
$q1="select * from ".$table_pre."client_pj where khid='".$khid."'";
$r1=$db->query($q1);
$ct1=1;
while($m1=$db->fetch_array($r1)){
$client=get_db_msg("select * from web_client where id='".$m1["cid"]."'");
$tbyd.="
| 序号 | 客户 | 评价星级 | 评价内容 |