7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
1460 lines
55 KiB
PHP
1460 lines
55 KiB
PHP
<?php
|
||
//订单管理
|
||
header("Content-type: text/html; charset=utf-8");
|
||
if(THIS_IN!="edt_admin")
|
||
exit("错误的访问!");
|
||
//-------------------------------execute action
|
||
$db=_mysql_connect();
|
||
$msg_login_user=get_db_msg("select * from ".$table_pre."user where id='".$uid."'");
|
||
//权限判断
|
||
$priv=return_priv($_m,$msg_login_user["priv"]);
|
||
$json_data="{";
|
||
//$sys_size_num=get_max_size_num();
|
||
//取得合并尺码
|
||
$arr_size_merged=get_size_merged();
|
||
$sys_size_num=count($arr_size_merged);
|
||
if($priv[0]=="n"){
|
||
//没有操作权限
|
||
$json_data.="\"error\":\"没有操作权限\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],";
|
||
}else{
|
||
$uid=check_cookie();
|
||
$json_data.="\"uid\":".$uid.",";
|
||
$db=_mysql_connect();
|
||
$msg_login_user=get_db_msg("select * from ".$table_pre."user where id='".$uid."'");
|
||
$zk_type=get_set("zk_type");
|
||
//文胸
|
||
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;
|
||
}
|
||
$is_multi_price=get_set("is_multi_price");
|
||
|
||
//取得选项
|
||
$arr_select_no=$arr_select_no1=array();
|
||
$arr_select_title=$arr_select_title1=array();
|
||
$q="select no,title from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' 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)){
|
||
if($m["no"]!="zd1" && $m["no"]!="zd2" && $m["no"]!="zd3"){
|
||
$arr_select_no1[]=$m["no"];
|
||
$arr_select_title1[]=$m["title"];
|
||
if($m["no"]!="designer"){
|
||
$arr_select_no2[]=$m["no"];
|
||
$arr_select_title2[]=$m["title"];
|
||
}
|
||
}
|
||
$arr_select_no[]=$m["no"];
|
||
$arr_select_title[]=$m["title"];
|
||
}
|
||
$arr_column_this=array("client"=>"客户代码","no"=>"款号","color"=>"颜色代码");
|
||
if($bx_sizegroup_id>0)
|
||
$arr_column_this["bx"]="杯型";
|
||
else if($child_sizegroup_id>0)
|
||
$arr_column_this["bx"]="款型";
|
||
if($is_gg!="n")
|
||
$arr_column_this["gg"]=d_translate("gg");
|
||
if($sys_ver_hy=="xz"){
|
||
$arr_column_this["xs"]="箱数";
|
||
}
|
||
switch($_a){
|
||
case "add" :
|
||
//--------------------------新增
|
||
$add_date=date("Y-m-d H:i:s");
|
||
if($id){
|
||
$msg=get_db_msg("select * from ".$table_pre."order where id='".$id."'");
|
||
$msg_kh=get_db_msg("select * from ".$table_pre."kh where id='".$msg["iid"]."'");
|
||
if($msg_kh["size_group"]==$bx_sizegroup_id){
|
||
$tmp=get_db_msg("select size from ".$table_pre."size_bx where no='".$msg_kh["no"]."' and bx='".$msg["bx"]."'");
|
||
$arr_size=explode(",",$tmp["size"]);
|
||
$bx_td="<td align=\"left\" bgcolor=\"#f0f0f0\">杯型</td>";
|
||
$bx="杯型";
|
||
$bxf="y";
|
||
}else if($msg_kh["size_group"]==$child_sizegroup_id){
|
||
$tmp=get_db_msg("select size from ".$table_pre."size_bx where no='".$msg_kh["no"]."' and bx='".$msg["bx"]."'");
|
||
$arr_size=explode(",",$tmp["size"]);
|
||
$bx_td="<td align=\"left\" bgcolor=\"#f0f0f0\">款型</td>";
|
||
$bx="款型";
|
||
$bxf="y";
|
||
}else{
|
||
$arr_size=explode(",",$msg_kh["size"]);
|
||
$bx_td="";
|
||
$bx="";
|
||
$bxf="n";
|
||
}
|
||
$is_ggk=is_ggk($msg_kh["id"]);
|
||
if($is_ggk!="n"){
|
||
$gg_td="<td align=\"left\" bgcolor=\"#f0f0f0\">".d_translate("gg")."</td>";
|
||
$gg=d_translate("gg");
|
||
$ggf="y";
|
||
}else{
|
||
$gg_td="";
|
||
$gg="";
|
||
$ggf="n";
|
||
}
|
||
//
|
||
$str_color=$str_color1="";
|
||
$sz="";
|
||
for($i=0;$i<count($arr_size);$i++){
|
||
$tmp=get_db_msg("select title from ".$table_pre."size where iid='".$msg_kh["size_group"]."' and no='".$arr_size[$i]."'");
|
||
$str_color.="<td width=\"40\" align=\"center\" bgcolor=\"#f0f0f0\">".$tmp["title"]."</td>";
|
||
$str_color1.="<td bgcolor=\"#ffffff\"><input type=\"text\" name=\"num_".$arr_size[$i]."\" value=\"".$msg["num_".$arr_size[$i]]."\" style=\"width:40px;\" /></td>";
|
||
$sz.="{\"no\":\"num_".$arr_size[$i]."\",\"title\":\"".$tmp["title"]."\",\"value\":\"".$msg["num_".$arr_size[$i]]."\"},";
|
||
}
|
||
$_nav_.=" > 修改订单";
|
||
}
|
||
$tmp=get_db_msg("select * from ".$table_pre."client where id='".$msg["uid"]."'");
|
||
|
||
$json_data.="\"dp\":\"".$tmp["title"]."\",";
|
||
$json_data.="\"kh\":\"".$msg["no"]."\",";
|
||
$color=$msg["color"]."-".get_cate_title_no("color",$msg["color"]);
|
||
$json_data.="\"color\":\"".$color."\",";
|
||
$json_data.="\"ggf\":\"".$ggf."\",";
|
||
$json_data.="\"ggt\":\"".$gg."\",";
|
||
$json_data.="\"gg\":\"".get_gg_title($msg["bx"])."\",";
|
||
|
||
$json_data.="\"bxf\":\"".$bxf."\",";
|
||
$json_data.="\"bxt\":\"".$bx."\",";
|
||
$json_data.="\"bx\":\"".$msg["bx"]."\",";
|
||
|
||
$sz=deel_end($sz);
|
||
|
||
$json_data.="\"size\":[".$sz."],";
|
||
|
||
$content[]=array("店铺",$tmp["title"]);
|
||
$content[]=array("款号",$msg["no"]);
|
||
if($msg_kh["size_group"]==$bx_sizegroup_id || $msg_kh["size_group"]==$child_sizegroup_id){
|
||
$select_bx="<td bgcolor=\"#ffffff\">".$msg["bx"]."</td>";
|
||
}
|
||
if($is_ggk!="n")
|
||
$select_gg="<td bgcolor=\"#ffffff\">".get_gg_title($msg["bx"])."</td>";
|
||
$content[]=array("数量","<table border=\"0\" cellspacing=\"1\" cellpadding=\"3\" bgcolor=\"#cccccc\"><tr><td align=\"left\" bgcolor=\"#f0f0f0\">颜色</td>".$gg_td.$bx_td.$str_color."</tr><tr><td bgcolor=\"#ffffff\">".$msg["color"]."-".get_cate_title_no("color",$msg["color"])."</td>".$select_bx.$select_gg.$str_color1."</tr></table>");
|
||
//js_code
|
||
$js_code="function ok(){
|
||
obj=document.form1;
|
||
return true;
|
||
}";
|
||
//
|
||
$form_property=" onsubmit=\"return ok()\"";
|
||
$form_hidden=array("id"=>$id,"_a"=>"save_add","http_pre"=>$_SERVER['HTTP_REFERER']);
|
||
//include template("manage_add");
|
||
break;
|
||
case "save_add" :
|
||
if($id){
|
||
$msg=get_db_msg("select * from ".$table_pre."order where id='".$id."'");
|
||
$msg_client=get_db_msg("select * from ".$table_pre."client where id='".$msg["uid"]."'");
|
||
$old_num=$msg["num"];
|
||
|
||
$log_hd_ms="后台修改订单";
|
||
$ip=$_SERVER["REMOTE_ADDR"];
|
||
$add_date=date("Y-m-d H:i:s");
|
||
|
||
$log_action="修改";
|
||
//检查订单数量
|
||
$c=0;
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$var1="num_".$s1;
|
||
$c+=$$var1;
|
||
}
|
||
$tmpnum=$old_num-$c;
|
||
$change_num=abs($tmpnum);
|
||
if($old_num>$c){
|
||
$action="22";
|
||
}else{
|
||
$action="23";
|
||
}
|
||
if($tmpnum==0){
|
||
$action="21";
|
||
}
|
||
if($c>0){
|
||
$query="update ".$table_pre."order set ".get_size_sql("update")." where id='".$id."'";
|
||
}else{
|
||
$query="delete from ".$table_pre."order where id='".$id."'";
|
||
$action="24";
|
||
}
|
||
$db->query($query);
|
||
$lid=$id;
|
||
//记录订单表sql日志
|
||
update_order_log($msg["uid"],$query);
|
||
|
||
//行为记录log
|
||
$q="insert into ".$table_pre."log_hd (uid,iid,num,ip,action,ms,hd_type,add_date) values ('".$msg["uid"]."','".$msg["iid"]."','".$change_num."','".$ip."','".$action."','".$log_hd_ms."','','".$add_date."')";
|
||
$db->query($q);
|
||
|
||
//缓存排行
|
||
count_ph($msg["uid"],$msg["iid"],$msg["color"]);
|
||
//缓存订单表
|
||
cache_order($msg["uid"],$msg["iid"],$msg["color"],$msg["bx"]);
|
||
//缓存客户表
|
||
set_order_total($msg["uid"]);
|
||
}
|
||
//echo $query."<br>";
|
||
if($msg["bx"])
|
||
$log_bx=",".$msg["bx"];
|
||
else
|
||
$log_bx="";
|
||
set_log($log_action."订单",$msg_client["username"].",".$msg["no"].",".$msg["color"].$log_bx."|".$msg["num"]."->".$c);
|
||
$json_data.="\"code\":1,";
|
||
//url_redirect($http_pre);
|
||
break;
|
||
case "del" :
|
||
$num=count($id);
|
||
for($i=0;$i<$num;$i++){
|
||
$tmp=get_db_msg("select * from ".$table_pre."order where id='".$id[$i]."'");
|
||
$old_num=$tmp["num"];
|
||
$action="24";
|
||
$log_hd_ms="后台删除订单";
|
||
$ip=$_SERVER["REMOTE_ADDR"];
|
||
$add_date=date("Y-m-d H:i:s");
|
||
//
|
||
$tmp1=get_db_msg("select * from ".$table_pre."client where id='".$tmp["uid"]."'");
|
||
//
|
||
$query="delete from ".$table_pre."order where id='".$id[$i]."'";
|
||
$db->query($query);
|
||
|
||
//删除配码表
|
||
$db->query("delete from ".$table_pre."order_pm where uid='".$tmp["uid"]."' and iid='".$tmp["iid"]."' and color='".$tmp["color"]."' and bx='".$tmp["bx"]."' and _key='".$tmp["_key"]."'");
|
||
|
||
//记录订单表sql日志
|
||
update_order_log($tmp["uid"],$query);
|
||
|
||
|
||
|
||
//行为记录log
|
||
$q="insert into ".$table_pre."log_hd (uid,iid,num,ip,action,ms,hd_type,add_date) values ('".$tmp["uid"]."','".$tmp["iid"]."','".$old_num."','".$ip."','".$action."','".$log_hd_ms."','','".$add_date."')";
|
||
$db->query($q);
|
||
|
||
//
|
||
set_order_total($tmp["uid"]);
|
||
//
|
||
count_ph($tmp["uid"],$tmp["iid"],$tmp["color"]);
|
||
if($tmp["bx"])
|
||
$log_bx=",".$tmp["bx"];
|
||
else
|
||
$log_bx="";
|
||
$lid.=$tmp1["username"]."-".$tmp["no"]."-".$tmp["color"].$log_bx.",".$tmp["num"]."件, ";
|
||
}
|
||
$lid=substr($lid,0,-2);
|
||
set_log("删除订单",$lid);
|
||
$json_data.="\"code\":1,";
|
||
//url_redirect();
|
||
break;
|
||
case "order_sql":
|
||
if($step=="2"){
|
||
$sql_con="";
|
||
//定制客户条件
|
||
if($s_username){
|
||
$s_username=str_replace(",",",",$s_username);
|
||
//去掉最后一个逗号
|
||
if(substr($s_username,strlen($s_username)-1,1)==",")
|
||
$s_username1=substr($s_username,0,-1);
|
||
else
|
||
$s_username1=$s_username;
|
||
$arr_username=explode(",",$s_username1);
|
||
//去掉重复值
|
||
$arr_username=array_unique($arr_username);
|
||
$str_uid="";
|
||
for($i=0;$i<count($arr_username);$i++){
|
||
//检查是否存在
|
||
$m_client=get_db_msg("select id,path,face from ".$table_pre."client where username='".$arr_username[$i]."'");
|
||
//
|
||
if($m_client["id"]){
|
||
if($m_client["face"]=="4"){
|
||
$str_uid.=$m_client["id"].",";
|
||
}else{
|
||
$q1="select id from ".$table_pre."client where (path='".$m_client["path"]."-".$m_client["id"]."' or path like '".$m_client["path"]."-".$m_client["id"]."-%') and face='4'";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$str_uid.=$m1["id"].",";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if($str_uid)
|
||
$sql_con.="uid in (".substr($str_uid,0,-1).") and ";
|
||
}
|
||
//定制时间条件
|
||
if($s_time){
|
||
$sql_con.="add_date<'".$s_time.":59' and ";
|
||
}
|
||
if($sql_con)
|
||
$sql_con="where ".substr($sql_con,0,-4);
|
||
$msg="";
|
||
//开始执行
|
||
$q="select * from ".$table_pre."order_log ".$sql_con." order by add_date";
|
||
//$msg.=$q."<Br>";
|
||
$r=$db->query($q);
|
||
$content1="";
|
||
while($m=$db->fetch_array($r)){
|
||
$content1.="#".$m["add_date"]."\n".$m["sql_value"].";\n";
|
||
}
|
||
$file_name="order_log_".date("Y-m-d-H-i-s").".sql";
|
||
write_file("cache",$file_name,$content1);
|
||
//$msg.="<div align='center'>".date("Y-m-d H:i:s").",日志生成完成!<br><a href='cache/".$file_name."'>下载(admin/debug/".$file_name.")</a>!</div>";
|
||
$z_time=date("Y-m-d-H-i-s");
|
||
}else{
|
||
$s_username="";
|
||
$file_name="";
|
||
$z_time="";
|
||
$s_time=date("Y-m-d H:i:s");
|
||
}
|
||
$json_data.="\"s_username\":\"".$s_username."\",";
|
||
$json_data.="\"file_name\":\"".$file_name."\",";
|
||
$json_data.="\"s_time\":\"".$s_time."\",";
|
||
$json_data.="\"z_time\":\"".$z_time."\",";
|
||
$json_data.="\"code\":1,";
|
||
//生成订单日志
|
||
/*$js_code="<script type=\"text/javascript\" src=\"js/jquery-1.4.4.min.js\"></script>
|
||
<script type=\"text/javascript\" src=\"js/jquery.autocomplete.js\"></script>
|
||
<link rel=\"Stylesheet\" href=\"css/jquery.autocomplete.css\" />";
|
||
$js_code.="<script>
|
||
function ok1(){
|
||
var f1=document.getElementById('form1');
|
||
document.getElementById('sub1').value='处理中...';
|
||
document.getElementById('sub1').disabled=true;
|
||
return true;
|
||
}";
|
||
$js_code.=get_client_autocompelete("","n")."\n";
|
||
$js_code.="$(function() {
|
||
$('#s_username').autocomplete(clients, {
|
||
max: 100, //列表里的条目数
|
||
minChars: 0, //自动完成激活之前填入的最小字符
|
||
width: 200, //提示的宽度,溢出隐藏
|
||
scrollHeight: 200, //提示的高度,溢出显示滚动条
|
||
matchContains: true, //包含匹配,就是data参数里的数据,是否只要包含文本框里的数据就显示
|
||
autoFill: false, //自动填充
|
||
multiple:true,
|
||
multipleSeparator:',',
|
||
formatItem: function(row, i, max) {
|
||
return row.t+'('+row.u+')';
|
||
},
|
||
formatMatch: function(row, i, max) {
|
||
return row.t + row.u;
|
||
},
|
||
formatResult: function(row) {
|
||
return row.u;
|
||
}
|
||
}).result(function(event, row, formatted) {
|
||
$('#s_username').value=row.u;
|
||
});
|
||
});";
|
||
$js_code.="</script>";
|
||
$content="<form id='form1' name='form1' action='".$_SERVER["PHP_SELF"]."' method='get' onsubmit='return ok1();'><input type='hidden' name='_cid' value='".$_cid."'><input type='hidden' name='_m' value='".$_m."'><input type='hidden' name='_a' value='".$_a."'><input type='hidden' name='step' value='2'><table border=\"0\" cellspacing=\"1\" cellpadding=\"3\" bgcolor=\"#ffffff\" width=\"100%\">";
|
||
$content.="<tr bgcolor='#cccccc' height='30'><td colspan='2' align='left'><b>生成订单sql日志文件</b></td></tr>";
|
||
$content.="<tr><td align='left' width='80'>选择客户</td><td><input type='text' id='s_username' name='s_username' value='".$s_username."'>(留空表示所有)</td></tr>";
|
||
$content.="<tr><td align='left'>输入时间</td><td><input type='text' id='s_time' name='s_time' value='".$s_time."'>之前</td></tr>";
|
||
$content.="<tr><td colspan='2' align='center'><input id='sub1' type='submit' value=' 提 交 '></td></tr>";
|
||
if($msg)
|
||
$content.="<tr><td colspan='2' align='left' style='line-height:150%;'>".$msg."</td></tr>";
|
||
$content.="</table></form>";
|
||
include template("blank");*/
|
||
break;
|
||
case "check":
|
||
//--------------------------------------------
|
||
$content="";
|
||
//
|
||
//检查颜色
|
||
$content.="<b>款号颜色检查:</b><br>";
|
||
$q="select no,color,iid from ".$table_pre."order where _key='".$_key."' group by no,color";
|
||
$r=$db->query($q);
|
||
$i=1;
|
||
$tmp="";
|
||
while($m=$db->fetch_array($r)){
|
||
$m_kh=get_db_msg("select no,color from ".$table_pre."kh where id='".$m["iid"]."'");
|
||
$arr_color=explode(",",$m_kh["color"]);
|
||
if(!in_array($m["color"],$arr_color)){
|
||
$content.=$i.".<a href=\"#\" onclick=\"window.opener.location.href='?_cid=".$_cid."&_m=".$_m."&s_color=".$m["color"]."&s_no=".$m_kh["no"]."'\">".$m_kh["no"]."|".$m["color"]."</a>--有误<br>";
|
||
$tmp.="{\"kh\":\"".$m_kh["no"]."\",\"v\":\"".$m_kh["no"]."|".$m["color"]."--有误\"},";
|
||
$i++;
|
||
}
|
||
}
|
||
if($i==1)
|
||
$content.="款号颜色检查完毕,没有错误!";
|
||
if($i>1){
|
||
$str.="{\"f\":\"1\",\"cate\":\"款号颜色有误\",\"data\":[".deel_end($tmp)."]},";
|
||
}
|
||
//检查客户
|
||
$content.="<hr><b>客户检查:</b><br>";
|
||
$q="select uid from ".$table_pre."order where _key='".$_key."' group by uid";
|
||
$r=$db->query($q);
|
||
$i=1;
|
||
$tmp="";
|
||
while($m=$db->fetch_array($r)){
|
||
$m_client=get_db_msg("select title,username from ".$table_pre."client where id='".$m["uid"]."'");
|
||
if(trim($m_client["username"])==""){
|
||
$content.=$i.".<a href=\"#\" onclick=\"window.opener.location.href='?_cid=".$_cid."&_m=".$_m."&s_uid=".$m["uid"]."'\">uid=".$m["uid"]."</a>--有误";
|
||
$tmp.="{\"dp\":\"".$m["uid"]."\",\"v\":\"uid=".$m["uid"]."--有误\"},";
|
||
$i++;
|
||
}
|
||
}
|
||
if($i==1)
|
||
$content.="客户检查完毕,没有错误!<br>";
|
||
|
||
if($i>1){
|
||
$str.="{\"f\":\"2\",\"cate\":\"客户有误\",\"data\":[".deel_end($tmp)."]},";
|
||
}
|
||
//检查异常重复记录
|
||
$content.="<hr><b>异常重复记录检查:</b><br>";
|
||
$q="select b.username 'username',a.no 'no',a.color 'color' ,a.bx 'bx' from ".$table_pre."order a,".$table_pre."client b where a.uid=b.id and a._key='".$_key."' group by a.uid,a.iid,a.color,a.bx having count(*)>1";
|
||
$r=$db->query($q);
|
||
$i=1;
|
||
$tmp="";
|
||
while($m=$db->fetch_array($r)){
|
||
$content.=$i.".<a href=\"#\" onclick=\"window.opener.location.href='?_cid=".$_cid."&_m=".$_m."&s_dp=".$m["username"]."&s_no=".$m["no"]."&s_color=".$m["color"]."'\">".$m["username"]."|".$m["no"]."|".$m["color"]."|".$m["bx"]."有误</a><br>";
|
||
$tmp.="{\"dp\":\"".$m["username"]."\",\"kh\":\"".$m["no"]."\",\"color\":\"".$m["color"]."\",\"v\":\"".$m["username"]."|".$m["no"]."|".$m["color"]."|".$m["bx"]."有误\"},";
|
||
$i++;
|
||
}
|
||
if($i==1)
|
||
$content.="异常重复检查完毕,没有错误!<br>";
|
||
|
||
if($i>1){
|
||
$str.="{\"f\":\"3\",\"cate\":\"异常重复记录检查\",\"data\":[".deel_end($tmp)."]},";
|
||
}
|
||
$json_data.="\"error\":[".deel_end($str)."],";
|
||
//include template("blank");
|
||
break;
|
||
case "mod_color":
|
||
|
||
if($step==1){
|
||
//-------------------检测
|
||
$q1="select * from ".$table_pre."order where iid='".$khid."' and color='".$color_from."' and _key='".$_key."'";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$check=get_db_msg("select * from ".$table_pre."order where iid='".$khid."' and color='".$color_to."' and bx='".$m1["bx"]."' and uid='".$m1["uid"]."' and _key='".$_key."'");
|
||
if($check["id"]>0){
|
||
//合并数据
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$v1="num_".$s1;
|
||
$$v1=$check[$v1]+$m1[$v1];
|
||
}
|
||
$q="update ".$table_pre."order set ".get_size_sql("update")." where id='".$check["id"]."'";
|
||
$db->query("delete from ".$table_pre."order where id='".$m1["id"]."'");
|
||
//记录订单表sql日志
|
||
update_order_log($m1["uid"],"delete from ".$table_pre."order where id='".$m1["id"]."'");
|
||
}else{
|
||
$q="update ".$table_pre."order set color='".$color_to."' where id='".$m1["id"]."'";
|
||
}
|
||
$db->query($q);
|
||
//记录订单表sql日志
|
||
update_order_log($m1["uid"],$q);
|
||
//
|
||
cache_order($m1["uid"],$m1["iid"],$m1["color"],$m1["bx"]);
|
||
}
|
||
//
|
||
//
|
||
if($sys_ver_hy=="xz"){
|
||
$q2="select * from ".$table_pre."order_pm where _key='".$_key."' and iid='".$khid."' and color='".$color_from."'";
|
||
$r2=$db->query($q2);
|
||
while($m2=$db->fetch_array($r2)){
|
||
$check2=get_db_msg("select * from ".$table_pre."order_pm where _key='".$_key."' and iid='".$khid."' and color='".$color_to."' and pmid='".$m2["pmid"]."' and uid='".$m2["uid"]."'");
|
||
if($check2["id"]>0){
|
||
$is_xd_clothes="y";
|
||
$msg_kh_to=get_db_msg("select * from ".$table_pre."kh where id='".$khid."'");
|
||
$msg_size_group=get_db_msg("select title from ".$table_pre."keyword where cate='size' and id='".$msg_kh_to["size_group"]."'");
|
||
if(in_array($msg_size_group["title"],$sys_size_group_xz))
|
||
$is_xd_clothes="n";
|
||
//合并数据
|
||
if($is_xd_clothes=="n"){
|
||
$vvv=$check2["xs"]+$m2["xs"];
|
||
}else{
|
||
$vvv=1;
|
||
}
|
||
|
||
$db->query("update ".$table_pre."order_pm set xs='".$vvv."',color='".$color_to."' where id='".$check2["id"]."'");
|
||
$db->query("delete from ".$table_pre."order_pm where id='".$m2["id"]."'");
|
||
}else{
|
||
$db->query("update ".$table_pre."order_pm set color='".$color_to."' where id='".$m2["id"]."'");
|
||
}
|
||
}
|
||
}
|
||
//
|
||
$msg_kh=get_db_msg("select * from ".$table_pre."kh where id='".$khid."'");
|
||
if($del_kh=="y"){
|
||
//删除款号颜色
|
||
$tmp=explode(",",$msg_kh["color"]);
|
||
$new_color="";
|
||
for($i=0;$i<count($tmp);$i++){
|
||
if($tmp[$i]!=$color_from){
|
||
$new_color.=$tmp[$i].",";
|
||
}
|
||
}
|
||
if($new_color)
|
||
$new_color=substr($new_color,0,-1);
|
||
//echo $new_color;
|
||
$db->query("update ".$table_pre."kh set color='".$new_color."' where id='".$khid."'");
|
||
//删除款色表的颜色
|
||
$db->query("delete from ".$table_pre."kh_color where iid='".$khid."' and color='".$color_from."'");
|
||
}
|
||
set_log("订单颜色批量修改",$msg_kh["no"].":".$color_from."->".$color_to);
|
||
$json_data.="\"code\":1,";
|
||
//alert_and_redirect("修改成功!",$_SERVER[PHP_SELF]."?_m=".$_m."&_cid=".$_cid."&_a=".$_a);
|
||
}
|
||
//include template("report");
|
||
break;
|
||
case "pick_color" :
|
||
//
|
||
$msg_kh=get_db_msg("select * from ".$table_pre."kh where no='".$kh."'");
|
||
$tmp="";
|
||
$arr_color=explode(",",$msg_kh["color"]);
|
||
for($i=0;$i<count($arr_color);$i++){
|
||
$tmp.="{\"no\":\"".$arr_color[$i]."\",\"title\":\"".$arr_color[$i]."-".get_cate_title_no("color",$arr_color[$i])."\"},";
|
||
}
|
||
$tmp=deel_end($tmp);
|
||
$json_data.="\"select_dz\":[".$tmp."],";
|
||
break;
|
||
case "copy":
|
||
function get_gs_num($num,$gs_con,$gs_num){
|
||
$r=0;
|
||
if($num>0){
|
||
if($gs_con=="*"){
|
||
$r=$num*$gs_num;
|
||
}else if($gs_con=="+"){
|
||
$r=$num+$gs_num;
|
||
}else if($gs_con=="-"){
|
||
$r=$num-$gs_num;
|
||
}else if($gs_con=="/"){
|
||
$r=$num/$gs_num;
|
||
}
|
||
}
|
||
$r=$r>0?round($r):0;
|
||
return $r;
|
||
}
|
||
$arr_cp_gs=array("*"=>"乘","+"=>"加","-"=>"减","/"=>"除");
|
||
//--------------------------------------------
|
||
//查询条件定制
|
||
$cp_gs_con=$cp_gs_con?$cp_gs_con:"*";
|
||
$cp_gs_num=$cp_gs_num?$cp_gs_num:1;
|
||
$login_by_select=get_set("login_by_select");
|
||
//取得店铺框
|
||
//取得不复制款的条件
|
||
//取得定制选项
|
||
$select_dz="";
|
||
$at=0;
|
||
for($i=0;$i<count($arr_select_no1);$i++){
|
||
//取得选项
|
||
$tmp="";
|
||
$r1=$db->query("select no,title from ".$table_pre."keyword where cate='".$arr_select_no1[$i]."' order by no");
|
||
while($m1=$db->fetch_array($r1)){
|
||
$tmp.="{\"no\":\"".$m1["title"]."\",\"title\":\"".$m1["title"]."\"},";
|
||
}
|
||
$tmp=deel_end($tmp);
|
||
$var="s_".$arr_select_no1[$i];
|
||
$select_dz.="{\"id\":\"con_kh_".$at."\",\"no\":\"".$arr_select_no1[$i]."\",\"title\":\"".$arr_select_title1[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
|
||
$at++;
|
||
}
|
||
$select_dz=deel_end($select_dz);
|
||
$json_data.="\"select_dz\":[".$select_dz."],";
|
||
$json_data.="\"ctsd\":\"".$at."\",";
|
||
|
||
$select_dz1="";
|
||
//取得选项
|
||
$tmp="";
|
||
foreach($arr_cp_gs as $n => $t){
|
||
$tmp.="{\"no\":\"".$n."\",\"title\":\"".$t."\"},";
|
||
}
|
||
$tmp=deel_end($tmp);
|
||
$select_dz1.="{\"no\":\"cp_gs_con\",\"title\":\"规则\",\"value\":\"*\",\"op\":[".$tmp."]},";
|
||
$select_dz1=deel_end($select_dz1);
|
||
$json_data.="\"select_dz1\":[".$select_dz1."],";
|
||
|
||
if($step==1){
|
||
$sql_con_kh=deel_sql_con_kh($con_kh);
|
||
//-------------------检测
|
||
$con_test=1;
|
||
if($cp_gs_con=="*")
|
||
$con_test=1*$cp_gs_num;
|
||
else if($cp_gs_con=="+")
|
||
$con_test=1+$cp_gs_num;
|
||
else if($cp_gs_con=="/")
|
||
$con_test=1/$cp_gs_num;
|
||
if($con_test<=0){
|
||
alert_and_back("订单复制公式有误!");
|
||
}
|
||
if($dp_from){
|
||
$total_num=0;
|
||
$s_username=str_replace(",",",",$dp_from);
|
||
//去掉最后一个逗号
|
||
if(substr($s_username,strlen($s_username)-1,1)==",")
|
||
$s_username1=substr($s_username,0,-1);
|
||
else
|
||
$s_username1=$s_username;
|
||
$arr_username=explode(",",$s_username1);
|
||
//去掉重复值
|
||
$arr_username=array_unique($arr_username);
|
||
$confirm_str=$p_title=$error="";
|
||
for($i=0;$i<count($arr_username);$i++){
|
||
//检查是否存在
|
||
$m_client=get_db_msg("select * from ".$table_pre."client where username='".$arr_username[$i]."'");
|
||
//
|
||
if($m_client["id"]){
|
||
$p_title.=$m_client["title"]."(".$m_client["username"]."),";
|
||
$tmp=get_db_msg("select sum(num) 'num' from ".$table_pre."order where ka<>'y' and uid='".$m_client["id"]."' and _key='".$_key."'".$sql_con_kh);
|
||
$total_num+=$tmp["num"];
|
||
}else{
|
||
$error.=$arr_username[$i].",";
|
||
}
|
||
}
|
||
}
|
||
if($p_title)
|
||
$p_title=substr($p_title,0,-1);
|
||
if($error)
|
||
$error=substr($error,0,-1);
|
||
$msg2=get_db_msg("select * from ".$table_pre."client where username='".$dp_to."'");
|
||
if(!$error && $msg2["id"]){
|
||
//
|
||
$msg.="您选择的来源店铺是".$p_title.",将复制订单总量".$total_num."件<Br>";
|
||
$msg.="您选择的目标店铺是".$msg2["title"]."(".$msg2["username"]."),当前订单总量".$msg2["order_num"]."件<Br>";
|
||
$json_data.="\"code\":1,\"msg\":\"".$msg."\",";
|
||
}else{
|
||
if($error)
|
||
$json_data.="\"code\":0,\"msg\":\"来源店铺错误(".$error.")!\",";
|
||
if(!$msg2["id"])
|
||
$json_data.="\"code\":0,\"msg\":\"目标店铺错误!\",";
|
||
}
|
||
if($m_client["id"]==$msg2["id"] && $cp_type!="1")
|
||
$json_data.="\"code\":0,\"msg\":\"条件错误(相同客户不能清空复制,这样操作相当于删除数据)!\",";
|
||
}else if($step==2){
|
||
//-------------------数据复制
|
||
|
||
$log_hd_ms="后台复制订单";
|
||
$ip=$_SERVER["REMOTE_ADDR"];
|
||
$add_date=date("Y-m-d H:i:s");
|
||
|
||
$sql_con_kh=deel_sql_con_kh($con_kh);
|
||
$msg_to=get_db_msg("select * from ".$table_pre."client where username='".$dp_to."'");
|
||
if($cp_type!="1"){
|
||
//先清空数据
|
||
$db->query("delete from ".$table_pre."order where uid='".$msg_to["id"]."' and ka<>'y' and _key='".$_key."'");
|
||
$db->query("delete from ".$table_pre."order_pm where _key='".$_key."' and uid='".$msg_to["id"]."'");
|
||
//记录订单表sql日志
|
||
update_order_log($msg_to["id"],"delete from ".$table_pre."order where uid='".$msg_to["id"]."' and ka<>'y' and _key='".$_key."'");
|
||
}
|
||
if($dp_from){
|
||
$s_username=str_replace(",",",",$dp_from);
|
||
//去掉最后一个逗号
|
||
if(substr($s_username,strlen($s_username)-1,1)==",")
|
||
$s_username1=substr($s_username,0,-1);
|
||
else
|
||
$s_username1=$s_username;
|
||
$arr_username=explode(",",$s_username1);
|
||
//去掉重复值
|
||
$arr_username=array_unique($arr_username);
|
||
$confirm_str=$p_title=$error="";
|
||
for($i=0;$i<count($arr_username);$i++){
|
||
//检查是否存在
|
||
$m_client=get_db_msg("select * from ".$table_pre."client where username='".$arr_username[$i]."'");
|
||
//
|
||
if($m_client["id"]){
|
||
if($m_client["face"]=="4"){
|
||
$con_u.=" (uid='".$m_client["id"]."') or ";
|
||
}else{
|
||
$con_u.=" (upath='".$m_client["path"]."-".$m_client["id"]."' or upath like '".$m_client["path"]."-".$m_client["id"]."-%') or ";
|
||
}
|
||
}else{
|
||
$error.=$arr_username[$i].",";
|
||
}
|
||
}
|
||
}
|
||
if($con_u)
|
||
$con_u=" and (".substr($con_u,0,-3).") ";
|
||
$q="select * from ".$table_pre."order where ka<>'y' and _key='".$_key."'".$con_u.$sql_con_kh;
|
||
//echo $q."<br>";
|
||
$r=$db->query($q);
|
||
while($m=$db->fetch_array($r)){
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$v1="num_".$s1;
|
||
$$v1=get_gs_num($m[$v1],$cp_gs_con,$cp_gs_num);
|
||
}
|
||
if(get_size_sql("count_total")>0){
|
||
$c=get_db_msg("select * from ".$table_pre."order where no='".$m["no"]."' and color='".$m["color"]."' and bx='".$m["bx"]."' and uid='".$msg_to["id"]."' and _key='".$_key."'");
|
||
if($c["id"]>0){
|
||
$old_num=$c["num"];
|
||
$new_num=0;
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$v1="num_".$s1;
|
||
$$v1+=$c[$v1];
|
||
$new_num+=$c[$v1];
|
||
}
|
||
$q1="update ".$table_pre."order set ".get_size_sql("update").",add_date='".time()."' where id='".$c["id"]."'";
|
||
$db->query($q1);
|
||
|
||
//行为记录log
|
||
$change_num=$new_num-$old_num;
|
||
$action="23";
|
||
$q="insert into ".$table_pre."log_hd (uid,iid,num,ip,action,ms,hd_type,add_date) values ('".$msg_to["id"]."','".$c["iid"]."','".$change_num."','".$ip."','".$action."','".$log_hd_ms."','','".$add_date."')";
|
||
$db->query($q);
|
||
|
||
//处理配码表
|
||
if($sys_ver_hy=="xz"){
|
||
$q2="select * from ".$table_pre."order_pm where _key='".$_key."' and iid='".$m["iid"]."' and uid='".$msg_to["id"]."' and color='".$m["color"]."' and bx='".$m["bx"]."'";
|
||
$r2=$db->query($q2);
|
||
while($m2=$db->fetch_array($r2)){
|
||
$c1=get_db_msg("select xs from ".$table_pre."order_pm where _key='".$_key."' and iid='".$m2["iid"]."' and uid='".$m["uid"]."' and color='".$m2["color"]."' and bx='".$m2["bx"]."' and pmid='".$m2["pmid"]."'");
|
||
$xs1=get_gs_num($c1["xs"],$cp_gs_con,$cp_gs_num);
|
||
$q1="update ".$table_pre."order_pm set xs=xs+".$xs1." where id='".$m2["id"]."'";
|
||
$db->query($q1);
|
||
}
|
||
}
|
||
}else{
|
||
$q1="insert into ".$table_pre."order (uid,upath,is_sp,iid,kh_dj,no,category,category1,season,sx,bc,series,brand,sxz,gender,theme,designer,price,price_zk,jgd,color,bx,size_group_id,".get_size_sql("insert1").",_key,add_date) values ('".$msg_to["id"]."','".$msg_to["path"]."-".$msg_to["id"]."','".$m["is_sp"]."','".$m["iid"]."','".$m["kh_dj"]."','".$m["no"]."','".$m["category"]."','".$m["category1"]."','".$m["season"]."','".$m["sx"]."','".$m["bc"]."','".$m["series"]."','".$m["brand"]."','".$m["sxz"]."','".$m["gender"]."','".$m["theme"]."','".$m["designer"]."','".$m["price"]."','".$m["price_zk"]."','".$m["jgd"]."','".$m["color"]."','".$m["bx"]."','".$m["size_group_id"]."',".get_size_sql("insert2").",'".$_key."','".time()."')";
|
||
$db->query($q1);
|
||
//行为记录log
|
||
$change_num=get_size_sql("count_total");
|
||
$action="21";
|
||
$q="insert into ".$table_pre."log_hd (uid,iid,num,ip,action,ms,hd_type,add_date) values ('".$msg_to["id"]."','".$m["iid"]."','".$change_num."','".$ip."','".$action."','".$log_hd_ms."','','".$add_date."')";
|
||
$db->query($q);
|
||
if($sys_ver_hy=="xz"){
|
||
//处理配码表
|
||
$q2="select * from ".$table_pre."order_pm where _key='".$_key."' and iid='".$m["iid"]."' and uid='".$m["uid"]."' and color='".$m["color"]."' and bx='".$m["bx"]."'";
|
||
$r2=$db->query($q2);
|
||
while($m2=$db->fetch_array($r2)){
|
||
//复制一份配码明细表
|
||
$m3=get_db_msg("select * from ".$table_pre."size_pm where id='".$m2["pmid"]."'");
|
||
$q4="insert into ".$table_pre."size_pm (title,uid,qyid,size_group_id,pm_dj,khid,gz,num) values ('".$m3["title"]."','".$msg_to["id"]."','".$m3["qyid"]."','".$m3["size_group_id"]."','".$m3["pm_dj"]."','".$m3["khid"]."','".$m3["gz"]."','".$m3["num"]."')";
|
||
$db->query($q4);
|
||
$pmid=$pmid=$db->insert_id();
|
||
//插入配码表记录
|
||
$xs1=get_gs_num($m2["xs"],$cp_gs_con,$cp_gs_num);
|
||
$q1="insert into ".$table_pre."order_pm (_key,uid,iid,color,bx,pmid,xs) values ('".$m2["_key"]."','".$msg_to["id"]."','".$m2["iid"]."','".$m2["color"]."','".$m2["bx"]."','".$pmid."','".$xs1."')";
|
||
$db->query($q1);
|
||
}
|
||
}
|
||
}
|
||
//echo $q1."<br>";
|
||
//记录订单表sql日志
|
||
update_order_log($msg_to["id"],$q1);
|
||
//
|
||
cache_order($msg_to["id"],$m["iid"],$m["color"],$m["bx"]);
|
||
}
|
||
}
|
||
set_order_total($msg_to["id"]);
|
||
$log_remark=$dp_from."到".$msg_to["username"].",".$msg_to["order_num"]."件";
|
||
set_log("复制订单",$log_remark);
|
||
$msg.="复制成功<Br>";
|
||
$msg_to=get_db_msg("select * from ".$table_pre."client where username='".$dp_to."'");
|
||
$msg.=$msg_to["title"].",当前订单总量".$msg_to["order_num"]."件<Br>";
|
||
$json_data.="\"code\":1,\"msg\":\"".$msg."\",";
|
||
}
|
||
//include template("report");
|
||
break;
|
||
//----------------------------------------------------------------------导入EXCEL
|
||
case "import":
|
||
//目录权限
|
||
$arr_path=array(
|
||
"cache"=>"admin/cache"
|
||
);
|
||
$json_data.="\"path_priv\":[";
|
||
$tmp="";
|
||
foreach($arr_path as $path_real => $path_title){
|
||
$tmp.="{\"title\":\"".$path_title."\",\"priv\":";
|
||
if(new_is_writeable($path_real)==1){
|
||
$tmp.="\"y\"";
|
||
}else{
|
||
$tmp.="\"n\"";
|
||
}
|
||
$tmp.="},";
|
||
}
|
||
$json_data.=substr($tmp,0,-1)."],";
|
||
break;
|
||
case "import_check":
|
||
$file1=$_FILES["up_file"];
|
||
//echo $file1["name"]."--";
|
||
$tmp_file_name=save_tmp_file($file1);
|
||
$tmp_content=get_tmp_content($tmp_file_name);
|
||
$arr_content=explode("\n",$tmp_content);
|
||
$arr_thead=get_table_thead($tmp_content);
|
||
$arr_column=check_table_thead($arr_thead,$arr_column_this);
|
||
$msg="";
|
||
//检测
|
||
$str_client=$str_no=$str_color=$str_bx=$str_size=$str_xs=$str_zxs="";
|
||
$ind_client=0;
|
||
$ind_no=1;
|
||
$ind_color=2;
|
||
$total_avail=0;
|
||
for($i=1;$i<count($arr_content);$i++){
|
||
$tmp_arr=explode("|^_^|",$arr_content[$i]);
|
||
$avail="y";
|
||
//检测客户代码
|
||
$tmp=get_db_msg("select * from ".$table_pre."client where username='".$tmp_arr[0]."' and face='4'");
|
||
if(!$tmp["id"]){
|
||
$str_client.="<span style='color:#ff0000;font-weight:bold;'>".$tmp_arr[0]."</span>,";
|
||
$avail="n";
|
||
}
|
||
//检测款号
|
||
$tmp=get_db_msg("select * from ".$table_pre."kh where no='".$tmp_arr[1]."'");
|
||
if($sys_ver_hy=="xz"){
|
||
$is_xd_clothes="y";
|
||
$msg_size_group=get_db_msg("select title from ".$table_pre."keyword where cate='size' and id='".$tmp["size_group"]."'");
|
||
if(in_array($msg_size_group["title"],$sys_size_group_xz))
|
||
$is_xd_clothes="n";
|
||
$xs=$tmp_arr[get_main_key($arr_thead,"箱数")];
|
||
if($is_xd_clothes!="n"){
|
||
//衣服箱数不允许大于一
|
||
if($xs>1){
|
||
$str_xs.="<span style='color:#ff0000;font-weight:bold;'>".$tmp_arr[1]."-".$tmp_arr[2]."</span>,";
|
||
$avail="n";
|
||
}
|
||
}
|
||
}
|
||
if($tmp["id"]>0){
|
||
//款号正确,检测颜色
|
||
$tmp1=get_db_msg("select * from ".$table_pre."keyword where cate='color' and no='".$tmp_arr[2]."'");
|
||
$arr_check_color=explode(",",$tmp["color"]);
|
||
if($tmp1["id"]>0 && in_array($tmp1["no"],$arr_check_color)){
|
||
//颜色正确
|
||
}else{
|
||
$str_color.="<span style='color:#ff0000;font-weight:bold;'>".$tmp_arr[1]."-".$tmp_arr[2]."</span>,";
|
||
$avail="n";
|
||
}
|
||
}else{
|
||
$str_no.="<span style='color:#ff0000;font-weight:bold;'>".$tmp_arr[1]."</span>,";
|
||
$avail="n";
|
||
}
|
||
|
||
//检测杯型
|
||
if($tmp["size_group"]>0 && $bx_sizegroup_id==$tmp["size_group"]){
|
||
$bx=deel_bx($tmp_arr[3]);
|
||
if($bx){
|
||
//杯型正确
|
||
}else{
|
||
//
|
||
$str_bx.="<span style='color:#ff0000;font-weight:bold;'>".$tmp_arr[3]."</span>,";
|
||
}
|
||
$size_start=4;
|
||
}else if($tmp["size_group"]>0 && $child_sizegroup_id==$tmp["size_group"]){
|
||
$bx=$tmp_arr[3];
|
||
if($bx){
|
||
//杯型正确
|
||
}else{
|
||
//
|
||
$str_bx.="<span style='color:#ff0000;font-weight:bold;'>".$tmp_arr[3]."</span>,";
|
||
}
|
||
$size_start=4;
|
||
}else{
|
||
if($bx_sizegroup_title!=""){
|
||
$size_start=4;
|
||
}else{
|
||
$size_start=3;
|
||
}
|
||
|
||
$bx="";
|
||
}
|
||
|
||
|
||
//检测规格
|
||
if($is_gg!="n"){
|
||
$is_gg_ks=is_gg_ks($tmp_arr[1],$tmp_arr[2]);
|
||
if($is_gg_ks=="y" && $tmp_arr[3]!=""){
|
||
$gg=get_gg_id($tmp_arr[3]);
|
||
if($gg>0){
|
||
//正确
|
||
}else{
|
||
//
|
||
$str_gg.="<span style='color:#ff0000;font-weight:bold;'>".$tmp_arr[1]."-".$tmp_arr[2]."-".$tmp_arr[3]."</span>,";
|
||
}
|
||
}else{
|
||
if($is_gg_ks!="y" && $tmp_arr[3]!=""){
|
||
$str_gg.="<span style='color:#ff0000;font-weight:bold;'>".$tmp_arr[1]."-".$tmp_arr[2]."不存在规格</span>,";
|
||
}
|
||
}
|
||
$size_start=4;
|
||
}
|
||
if($avail=="y"){
|
||
if($sys_ver_hy=="xz"){
|
||
for($j=$size_start;$j<count($tmp_arr)-1;$j++){
|
||
$total_avail+=$tmp_arr[$j]*$xs;
|
||
}
|
||
}else{
|
||
for($j=$size_start;$j<count($tmp_arr);$j++){
|
||
$total_avail+=$tmp_arr[$j];
|
||
}
|
||
}
|
||
|
||
}
|
||
//检测每个尺码
|
||
$num_tal=0;
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$v1="num_".$s1;
|
||
$ind=$s1+$size_start-1;
|
||
$$v1=$tmp_arr[$ind];
|
||
$num_tal+=$$v1;
|
||
if($$v1>0){
|
||
|
||
|
||
|
||
//检测这个尺码是否有效
|
||
if($tmp["size_group"]>0 && ($bx_sizegroup_id==$tmp["size_group"] || $child_sizegroup_id==$tmp["size_group"])){
|
||
$tmp_size=get_db_msg("select id,size from ".$table_pre."size_bx where no='".$tmp_arr[1]."' and bx='".$tmp_arr[3]."'");
|
||
if(!$tmp_size["id"]){
|
||
$tmp_size=get_db_msg("select size from ".$table_pre."kh where no='".$tmp_arr[1]."'");
|
||
}
|
||
}else{
|
||
$tmp_size=get_db_msg("select size from ".$table_pre."kh where no='".$tmp_arr[1]."'");
|
||
}
|
||
|
||
$tmp_size_arr=explode(",",$tmp_size["size"]);
|
||
|
||
if(in_array($s1,$tmp_size_arr)){
|
||
$sql_bx=$str_bx1="";
|
||
if($size_start==4){
|
||
$sql_bx=" and bx='".$tmp_arr[3]."'";
|
||
$str_bx1="-".$tmp_arr[3];
|
||
}
|
||
//检查不予下单尺码
|
||
$tmp_size_not=get_db_msg("select size from ".$table_pre."size_not where kh='".$tmp_arr[1]."' and color='".$tmp_arr[2]."'".$sql_bx);
|
||
$tmp_size_arr=explode(",",$tmp_size_not["size"]);
|
||
if(in_array($s1,$tmp_size_arr)){
|
||
//
|
||
$str_size.=$tmp_arr[1]."-".$tmp_arr[2].$str_bx1.":第".$s1."个尺码".$$v1."件<br>";
|
||
}
|
||
}else{
|
||
$str_size.=$tmp_arr[1].":第".$s1."个尺码".$$v1."件<br>";
|
||
}
|
||
}
|
||
}
|
||
|
||
//装箱数检查
|
||
if($sys_ver_hy=="xz"){
|
||
if($is_xd_clothes=="n"){
|
||
$arr_zxs=array();
|
||
$sql_zxs="select * from web_gz where cate='zxs' and kh='".$tmp_arr[1]."'";
|
||
$res_zxs=$db->query($sql_zxs);
|
||
while($msg_zxs=$db->fetch_array($res_zxs)){
|
||
$arr_zxs[]=$msg_zxs["num"];
|
||
}
|
||
if(is_array($arr_zxs)){
|
||
if(!in_array($num_tal,$arr_zxs)){
|
||
$str_zsx.="<span style='color:#ff0000;font-weight:bold;'>".$tmp_arr[1]."-".$tmp_arr[2]."</span>,";
|
||
}
|
||
}else{
|
||
$str_zsx.="<span style='color:#ff0000;font-weight:bold;'>".$tmp_arr[1]."-".$tmp_arr[2]."</span>,";
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
$str_check="";
|
||
if($str_client)
|
||
$str_check.="客户代码有误,请检查:".substr($str_client,0,-1)."<br>";
|
||
if($str_no)
|
||
$str_check.="款号有误,请检查:".substr($str_no,0,-1)."<br>";
|
||
if($str_color)
|
||
$str_check.="颜色代码有误,请检查:".substr($str_color,0,-1)."<br>";
|
||
if($str_bx)
|
||
$str_check.="杯型有误,请检查:".substr($str_bx,0,-1)."<br>";
|
||
if($str_gg)
|
||
$str_check.=d_translate("gg")."有误,请检查:".substr($str_gg,0,-1)."<br>";
|
||
if($str_size)
|
||
$str_check.="尺码有误,请检查:".substr($str_size,0,-1)."<br>";
|
||
if($str_xs)
|
||
$str_check.="箱数有误(衣服箱数不允许大于1),请检查:".substr($str_xs,0,-1)."<br>";
|
||
if($str_zsx)
|
||
$str_check.="装箱数有误,请检查:".substr($str_zsx,0,-1)."<br>";
|
||
|
||
$msg.=$str_check;
|
||
if(count($arr_column[0])==0){
|
||
$msg.="未检测到可导入字段,请返回检查EXCEL文件!";
|
||
del_tmp_file($tmp_file_name);
|
||
}
|
||
if($msg){
|
||
$json_data.="\"code\":0,\"msg\":\"".$msg."\",";
|
||
}else{
|
||
$msg1[0]=array("字段检测结果","无误");
|
||
//
|
||
$total=count($arr_content)-1;
|
||
$msg1[1]=array("本次有效订单总量",$total_avail);
|
||
$m1="";
|
||
for($i=0;$i<count($msg1);$i++){
|
||
$m1.="{\"col1\":\"".$msg1[$i][0]."\",\"col2\":\"".$msg1[$i][1]."\"},";
|
||
}
|
||
if($m1)
|
||
$m1=substr($m1,0,-1);
|
||
$json_data.="\"code\":1,\"tmp_file_name\":\"".$tmp_file_name."\",\"msg\":[".$m1."],";
|
||
$json_data.="\"input\":[{\"type\":\"radio\",\"title\":\"导入方式\",\"name\":\"import_type\",\"op\":\"清空导入|新增导入\",\"value\":\"清空导入\"}],";
|
||
}
|
||
break;
|
||
case "import_do":
|
||
$import_type=($import_type=="清空导入")?"y":"n";
|
||
$json_data.="\"code\":1,\"reload_type\":\"1\",";
|
||
//-------------------------------------------导入数据
|
||
$tmp_content=get_tmp_content($tmp_file_name);
|
||
$arr_content=explode("\n",$tmp_content);
|
||
$arr_thead=get_table_thead($tmp_content);
|
||
$arr_column=check_table_thead($arr_thead,$arr_column_this);
|
||
//清空订单处理
|
||
if($import_type=="y"){
|
||
$ii_arr=array();
|
||
for($ii=1;$ii<count($arr_content);$ii++){
|
||
$tmp_arr_ii=explode("|^_^|",$arr_content[$ii]);
|
||
$ii_arr[]=$tmp_arr_ii[0];
|
||
}
|
||
$result_ii=array_unique($ii_arr);
|
||
if(is_array($result_ii)){
|
||
foreach($result_ii as $key1=>$val2){
|
||
$tmp_client_ii=get_db_msg("select id from web_client where username='".$val2."'");
|
||
$db->query("delete from ".$table_pre."order where uid='".$tmp_client_ii["id"]."';");
|
||
//删除配码表
|
||
$db->query("delete from ".$table_pre."order_pm where uid='".$tmp_client_ii["id"]."'");
|
||
}
|
||
}
|
||
}
|
||
$log_hd_ms="后台导入订单";
|
||
$ip=$_SERVER["REMOTE_ADDR"];
|
||
$add_date=date("Y-m-d H:i:s");
|
||
|
||
//
|
||
$size_arr=array();
|
||
$res_size=$db->query("select id,title from ".$table_pre."keyword where cate='size'");
|
||
while($msg_size=$db->fetch_array($res_size)){
|
||
$size_arr[$msg_size["id"]]=$msg_size["title"];
|
||
}
|
||
$total_avail=0;
|
||
for($i=1;$i<count($arr_content);$i++){
|
||
$tmp_arr=explode("|^_^|",$arr_content[$i]);
|
||
$avail="y";
|
||
//检测客户代码
|
||
$tmp=get_db_msg("select * from ".$table_pre."client where username='".$tmp_arr[0]."' and face='4'");
|
||
if($tmp["id"]>0){
|
||
//客户代码正确
|
||
$uid1=$tmp["id"];
|
||
}else{
|
||
$avail="n";
|
||
}
|
||
//检测款号
|
||
$tmp=get_db_msg("select * from ".$table_pre."kh where no='".$tmp_arr[1]."'");
|
||
$iid=$tmp["id"];
|
||
//鞋子版本箱数设置
|
||
if($sys_ver_hy=="xz"){
|
||
$is_xd_clothes="y";
|
||
if(in_array($size_arr[$tmp["size_group"]],$sys_size_group_xz))
|
||
$is_xd_clothes="n";
|
||
if($is_xd_clothes=="n"){
|
||
$xs=$tmp_arr[get_main_key($arr_thead,"箱数")];
|
||
}else{
|
||
$xs=1;
|
||
}
|
||
}
|
||
$m_kh=$tmp;
|
||
//款号正确,检测颜色
|
||
$tmp1=get_db_msg("select no from ".$table_pre."keyword where cate='color' and no='".$tmp_arr[2]."'");
|
||
$color=$tmp1["no"];
|
||
//检测杯型
|
||
if($bx_sizegroup_id==$tmp["size_group"]){
|
||
$bx=deel_bx($tmp_arr[3]);
|
||
if($bx){
|
||
//杯型正确
|
||
}else{
|
||
//
|
||
$avail="n";
|
||
}
|
||
$size_start=4;
|
||
}else if($child_sizegroup_id==$tmp["size_group"]){
|
||
$bx=$tmp_arr[3];
|
||
if($bx){
|
||
//杯型正确
|
||
}else{
|
||
//
|
||
$avail="n";
|
||
}
|
||
$size_start=4;
|
||
}else{
|
||
$bx="";
|
||
if($bx_sizegroup_title!=""){
|
||
$size_start=4;
|
||
}else{
|
||
$size_start=3;
|
||
}
|
||
}
|
||
//检测规格
|
||
if($is_gg=="y"){
|
||
$size_start=4;
|
||
}
|
||
if($avail=="y"){
|
||
if($sys_ver_hy=="xz"){
|
||
$pm_gz="";
|
||
$arr_size1=explode(",",$m_kh["size"]);
|
||
for($j=0;$j<count($arr_size1);$j++){
|
||
$v1="num_".$arr_size1[$j];
|
||
$$v1=$tmp_arr[$size_start+$arr_size1[$j]-1]*$xs;
|
||
$pm_gz.=deel_num($tmp_arr[$size_start+$arr_size1[$j]-1]).":";
|
||
$total_avail+=$$v1;
|
||
}
|
||
}else{
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$v1="num_".$s1;
|
||
$ind=$s1+$size_start-1;
|
||
$$v1=$tmp_arr[$ind];
|
||
$total_avail+=$tmp_arr[$ind];
|
||
}
|
||
}
|
||
//导入数据
|
||
if(get_size_sql("count_total")>0){
|
||
$msg_to=get_db_msg("select * from ".$table_pre."client where id='".$uid1."'");
|
||
$m=get_db_msg("select * from ".$table_pre."kh where id='".$iid."'");
|
||
$c=get_db_msg("select * from ".$table_pre."order where iid='".$iid."' and color='".$color."' and bx='".$bx."' and uid='".$uid1."' and _key='".$_key."'");
|
||
//判断是否有规格
|
||
$is_ggk=is_ggk($iid);
|
||
$gg_color=$color;
|
||
$gg=$bx;
|
||
if($c["id"]>0){
|
||
$old_num=$c["num"];
|
||
$new_num=0;
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$v1="num_".$s1;
|
||
$$v1+=$c[$v1];
|
||
$new_num+=$c[$v1];
|
||
}
|
||
//行为记录log
|
||
$change_num=$new_num-$old_num;
|
||
$action="23";
|
||
$q="insert into ".$table_pre."log_hd (uid,iid,num,ip,action,ms,hd_type,add_date) values ('".$msg_to["id"]."','".$c["iid"]."','".$change_num."','".$ip."','".$action."','".$log_hd_ms."','','".$add_date."')";
|
||
$db->query($q);
|
||
$q1="update ".$table_pre."order set ".get_size_sql("update").",add_date='".time()."' where id='".$c["id"]."'";
|
||
cache_order($uid1,$iid,$color,$bx);
|
||
}else{
|
||
//判断是否是删除款
|
||
$ka="n";
|
||
if($m["ka"]=="y"){
|
||
$ka="y";
|
||
}else{
|
||
$tmp=explode(",",$m["color_ka"]);
|
||
if(in_array($color,$tmp))
|
||
$ka="y";
|
||
}
|
||
//行为记录log
|
||
$change_num=get_size_sql("count_total");
|
||
$action="21";
|
||
$q="insert into ".$table_pre."log_hd (uid,iid,num,ip,action,ms,hd_type,add_date) values ('".$msg_to["id"]."','".$m["id"]."','".$change_num."','".$ip."','".$action."','".$log_hd_ms."','','".$add_date."')";
|
||
$db->query($q);
|
||
//
|
||
$q1="insert into ".$table_pre."order (uid,upath,iid,kh_dj,no,category,category1,season,sx,bc,series,brand,sxz,gender,theme,designer,price,price_zk,jgd,color,bx,ka,size_group_id,".get_size_sql("insert1").",_key,add_date) values ('".$uid1."','".$msg_to["path"]."-".$msg_to["id"]."','".$m["id"]."','".$m["kh_dj"]."','".$m["no"]."','".$m["category"]."','".$m["category1"]."','".$m["season"]."','".$m["sx"]."','".$m["bc"]."','".$m["series"]."','".$m["brand"]."','".$m["sxz"]."','".$m["gender"]."','".$m["theme"]."','".$m["designer"]."','".get_price_dp($uid1,$m["id"])."','".$m["price_zk"]."','".$m["jgd"]."','".$color."','".$bx."','".$ka."','".$m["size_group"]."',".get_size_sql("insert2").",'".$_key."','".time()."')";
|
||
}
|
||
//echo $q1."<br>";
|
||
$db->query($q1);
|
||
|
||
//判断是否采用服装版本下单
|
||
if($sys_ver_hy=="xz"){
|
||
//计算配码规则
|
||
if($pm_gz)
|
||
$pm_gz=substr($pm_gz,0,-1);
|
||
//取得配码id
|
||
$m_pm=get_db_msg("select id from ".$table_pre."size_pm where uid='".$uid1."' and gz='".$pm_gz."'");
|
||
if($m_pm["id"]>0){
|
||
$pmid=$m_pm["id"];
|
||
}else{
|
||
$pm_title="临时".get_rand_num(4);
|
||
$pm_num=count_pm_num($pm_gz);
|
||
$q="insert into ".$table_pre."size_pm (qyid,uid,size_group_id,pm_dj,khid,title,gz,num) values ('0','".$uid1."','".$m["size_group"]."','临时配码','".$m["id"]."','".$pm_title."','".$pm_gz."','".$pm_num."')";
|
||
//echo $q."<br>";
|
||
$db->query($q);
|
||
$pmid=$db->insert_id();
|
||
}
|
||
$tmp_ord_pm=get_db_msg("select id,xs from web_order_pm where _key='".$_key."' and uid='".$uid1."' and iid='".$m["id"]."' and color='".$color."' and bx='".$bx."' and pmid='".$pmid."' limit 0,1");
|
||
if($tmp_ord_pm["id"]>0){
|
||
if($is_xd_clothes=="n"){
|
||
$dqsx=$xs+$tmp_ord_pm["xs"];
|
||
$q="update ".$table_pre."order_pm set xs='".$dqsx."' where id='".$tmp_ord_pm["id"]."'";
|
||
}else{
|
||
$q="update ".$table_pre."order_pm set xs='1' where id='".$tmp_ord_pm["id"]."'";
|
||
}
|
||
$db->query($q);
|
||
}else{
|
||
$q="insert into ".$table_pre."order_pm (_key,uid,iid,color,bx,pmid,xs) values ('".$_key."','".$uid1."','".$m["id"]."','".$color."','".$bx."','".$pmid."','".$xs."')";
|
||
$db->query($q);
|
||
}
|
||
}
|
||
//记录订单表sql日志
|
||
update_order_log($uid1,$q1);
|
||
//
|
||
cache_order($uid1,$m["id"],$color,$bx);
|
||
//------------------------------导入订单配码表
|
||
}
|
||
set_order_total($uid1);
|
||
}
|
||
}
|
||
//
|
||
del_tmp_file($tmp_file_name);
|
||
$log_remark=$msg_to["username"].",".$total_avail."件";
|
||
set_log("导入订单",$log_remark);
|
||
|
||
break;
|
||
//----------------------------------------------------------------------/导入EXCEL
|
||
case "cache_order":
|
||
if($step==1){
|
||
$con_u=$con_kh="";
|
||
if($s_uid && $s_uid!="all"){
|
||
$m_client=get_db_msg("select * from ".$table_pre."client where id='".$s_uid."'");
|
||
if($m_client["face"]=="4")
|
||
$con_u=" and uid='".$m_client["id"]."'";
|
||
else
|
||
$con_u=" and upath like '".$m_client["path"]."-".$m_client["id"]."-%'";
|
||
}else{
|
||
$con_u="";
|
||
}
|
||
if($s_kh){
|
||
$tmp=get_db_msg("select id from ".$table_pre."kh where no='".$s_kh."'");
|
||
if($tmp["id"]>0)
|
||
$con_kh=" and iid='".$tmp["id"]."'";
|
||
}
|
||
//-------------------检测
|
||
$step=500;
|
||
//$step=1;
|
||
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."order where iid>0 and _key='".$_key."' ".$con_u.$con_kh." order by id");
|
||
//echo "select count(*) 'num' from ".$table_pre."order where iid>0 ".$con_u.$con_kh." order by id";
|
||
$total=$tmp["num"];
|
||
//$total=9;
|
||
$next=$next?$next:1;
|
||
$limit1=($next-1)*$step;
|
||
$q="select uid,iid,color,bx from ".$table_pre."order where iid>0 and _key='".$_key."' ".$con_u.$con_kh." order by id limit ".$limit1.",".$step;
|
||
if($total-$next*$step<0){
|
||
$r=$db->query($q);
|
||
while($m=$db->fetch_array($r)){
|
||
cache_order($m["uid"],$m["iid"],$m["color"],$m["bx"]);
|
||
}
|
||
$msg=$total."条订单缓存完成!";
|
||
$ok="y";
|
||
}else{
|
||
$r=$db->query($q);
|
||
while($m=$db->fetch_array($r)){
|
||
cache_order($m["uid"],$m["iid"],$m["color"],$m["bx"]);
|
||
}
|
||
$msg=($next*$step)."/".$total."条订单缓存完成,还在努力处理中...";
|
||
$next++;
|
||
//$url=$_SERVER["PHP_SELF"]."?_m=".$_m."&_cid=".$_cid."&s_uid=".$s_uid."&s_kh=".$s_kh."&_a=cache_order&step=1&&next=".$next;
|
||
//url_redirect($url);
|
||
$ok="n";
|
||
}
|
||
$json_data.="\"msg\":\"".$msg."\",";
|
||
$json_data.="\"s_uid\":\"".$s_uid."\",";
|
||
$json_data.="\"s_kh\":\"".$s_kh."\",";
|
||
$json_data.="\"next\":\"".$next."\",";
|
||
$json_data.="\"total\":\"".$total."\",";
|
||
$json_data.="\"ok\":\"".$ok."\",";
|
||
$json_data.="\"code\":1,";
|
||
}else{
|
||
//include template("report");
|
||
}
|
||
break;
|
||
case "cache_client":
|
||
if($step==1){
|
||
//重新缓存客户表的金额字段
|
||
if($s_uid && $s_uid!="all"){
|
||
$m_client=get_db_msg("select * from ".$table_pre."client where id='".$s_uid."'");
|
||
if($m_client["face"]=="4")
|
||
$con_u=" where id='".$m_client["id"]."'";
|
||
else
|
||
$con_u=" where (path like '".$m_client["path"]."-".$m_client["id"]."-%' or path='".$m_client["path"]."-".$m_client["id"]."')";
|
||
}else{
|
||
$con_u="";
|
||
}
|
||
//$json_data.="\"s_uid\":\"".$s_uid."\",";
|
||
$list=$list?$list:1;
|
||
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client".$con_u);
|
||
//$json_data.="\"q\":\"select count(*) 'num' from ".$table_pre."client".$con_u."\",";
|
||
|
||
$total=$tmp["num"];
|
||
if(!$id){
|
||
//
|
||
$tmp=get_db_msg("select min(id) 'id' from ".$table_pre."client".$con_u);
|
||
$this_id=$tmp["id"];
|
||
}else{
|
||
if($con_u)
|
||
$tmp1=$con_u." and id>'".$id."'";
|
||
else
|
||
$tmp1=" where id>'".$id."'";
|
||
$tmp=get_db_msg("select min(id) 'id' from ".$table_pre."client ".$tmp1);
|
||
$this_id=$tmp["id"];
|
||
}
|
||
//取得最大id
|
||
$tmp=get_db_msg("select max(id) 'id' from ".$table_pre."client".$con_u);
|
||
if($id<$tmp["id"]){
|
||
$m_client=get_db_msg("select * from ".$table_pre."client where id='".$this_id."'");
|
||
set_order_total($this_id);
|
||
//echo $list."/".$total.":".$m_client["title"]."(".$m_client["username"]."),缓存完成,<a href=\"".$_SERVER["PHP_SELF"]."?_m=".$_m."&_cid=".$_cid."&_a=cache_client\">暂停</a><br>";
|
||
//
|
||
$msg=$list."/".$total.":".$m_client["title"]."(".$m_client["username"]."),缓存完成";
|
||
$list++;
|
||
//$url=$_SERVER["PHP_SELF"]."?_m=".$_m."&_cid=".$_cid."&s_uid=".$s_uid."&step=1&_a=cache_client&id=".$this_id."&list=".$list;
|
||
//url_redirect($url);
|
||
$ok="n";
|
||
}else{
|
||
set_order_total($s_uid);
|
||
//echo $total."个客户缓存完成!<a href=\"".$_SERVER["PHP_SELF"]."?_m=".$_m."&_cid=".$_cid."\">返回</a>";
|
||
$msg=$total."个客户缓存完成!";
|
||
$ok="y";
|
||
}
|
||
$json_data.="\"s_uid\":\"".$s_uid."\",";
|
||
$json_data.="\"list\":\"".$list."\",";
|
||
$json_data.="\"id\":\"".$this_id."\",";
|
||
$json_data.="\"msg\":\"".$msg."\",";
|
||
$json_data.="\"total\":\"".$total."\",";
|
||
$json_data.="\"ok\":\"".$ok."\",";
|
||
$json_data.="\"code\":1,";
|
||
}else{
|
||
//include template("report");
|
||
}
|
||
break;
|
||
case "cache_ph":
|
||
cache_ph();
|
||
//$json_data.="\"code\":1,";
|
||
break;
|
||
//-------------主界面
|
||
default :
|
||
//
|
||
$page=$page>0?$page:1;
|
||
$limit=$limit>0?$limit:10;
|
||
$start=($page-1)*$limit;
|
||
$end=$limit;
|
||
$order=$order?$order:"add_date!";
|
||
|
||
$s_key=$s_key?$s_key:$_key;
|
||
$s_ka=$s_ka?$s_ka:"n";
|
||
|
||
$sql_con="";
|
||
if($s_key)
|
||
$sql_con.="_key='".$s_key."' and ";
|
||
if($s_dp){
|
||
$tmp=get_db_msg("select * from ".$table_pre."client where username='".$s_dp."'");
|
||
if($tmp["id"]>0)
|
||
$sql_con.="uid='".$tmp["id"]."' and ";
|
||
else
|
||
alert_and_back("店铺代码有误,请检查!");
|
||
}
|
||
if($s_ka && $s_ka<>"show_all")
|
||
$sql_con.="ka='".$s_ka."' and ";
|
||
if($s_no)
|
||
$sql_con.="no like '%".$s_no."%' and ";
|
||
if($s_color)
|
||
$sql_con.="color='".$s_color."' and ";
|
||
if($s_uid)
|
||
$sql_con.="uid='".$s_uid."' and ";
|
||
if($sql_con)
|
||
$sql_con="where ".substr($sql_con,0,-4);
|
||
$sql_order=str_replace("!"," desc",$order);
|
||
$query="select count(*) 'total' from ".$table_pre."order ".$sql_con." and _key='".$_key."'";
|
||
$res=$db->query($query);
|
||
$msg=$db->fetch_array($res);
|
||
$total=$msg["total"];
|
||
|
||
$select_dz="";
|
||
//取得选项
|
||
$tmp="";
|
||
$tmp.="{\"no\":\"show_all\",\"title\":\"全部\"},";
|
||
foreach($arr_yn as $v => $t){
|
||
$tmp.="{\"no\":\"".$v."\",\"title\":\"".$t."\"},";
|
||
}
|
||
$tmp=deel_end($tmp);
|
||
$var="s_ka";
|
||
$select_dz.="{\"no\":\"ka\",\"title\":\"-是否删除款-\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
|
||
|
||
|
||
|
||
$tmp="";
|
||
$r1=$db->query("select * from ".$table_pre."keyword where cate='color' ");
|
||
while($m1=$db->fetch_array($r1)){
|
||
$tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
|
||
}
|
||
$tmp=deel_end($tmp);
|
||
$var="s_color";
|
||
$select_dz.="{\"no\":\"color\",\"title\":\"-颜色-\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
|
||
|
||
|
||
$select_dz=deel_end($select_dz);
|
||
$json_data.="\"select_dz\":[".$select_dz."],";
|
||
|
||
|
||
//------------
|
||
$query="select * from ".$table_pre."order ".$sql_con." and _key='".$_key."' order by ".$sql_order." limit ".$start.",".$end;
|
||
//echo $query."<br>";
|
||
$res=$db->query($query);
|
||
$count=0;
|
||
$json_data.="\"code\":0,\"msg\":\"\",\"count\":".$total.",\"data\":[";
|
||
$str_tmp="";
|
||
while($msg=$db->fetch_array($res)){
|
||
$list=$start+$count+1;
|
||
$content[$count][]=$list;
|
||
$content[$count][]=get_main_value($arr_yn,$msg["ka"]);
|
||
|
||
$tmp=get_db_msg("select username,title from ".$table_pre."client where id='".$msg["uid"]."'");
|
||
|
||
$str_tmp.="{";
|
||
$str_tmp.="\"id\":\"".$msg["id"]."\",";
|
||
$str_tmp.="\"cid\":\"".$msg["uid"]."\",";
|
||
$str_tmp.="\"xh\":\"".$list."\",";
|
||
$ka=get_main_value($arr_yn,$msg["ka"]);
|
||
$str_tmp.="\"ka\":\"".$ka."\",";
|
||
$str_tmp.="\"title\":\"".$tmp["title"]."\",";
|
||
$str_tmp.="\"username\":\"".$tmp["username"]."\",";
|
||
$dp=$tmp["title"]."(".$tmp["username"].")";
|
||
$str_tmp.="\"dp\":\"".$dp."\",";
|
||
$str_tmp.="\"kh\":\"".$msg["no"]."\",";
|
||
$color=$msg["color"]."-".get_cate_title_no("color",$msg["color"]);
|
||
$str_tmp.="\"color\":\"".$color."\",";
|
||
//$str_tmp.="\"color\":\"".$msg["color"]."\",";
|
||
if($bx_sizegroup_id>0 || $child_sizegroup_id>0)
|
||
$str_tmp.="\"bx\":\"".$msg["bx"]."\",";
|
||
if($is_gg!="n")
|
||
$str_tmp.="\"gg\":\"".get_gg_title($msg["bx"])."\",";
|
||
|
||
//$str_tmp.="\"color\":\"".$msg["color"]."\",";
|
||
$date=date("Y-m-d H:i",$msg["add_date"]);
|
||
$str_tmp.="\"date\":\"".$date."\",";
|
||
//
|
||
|
||
$content[$count][]=$tmp["title"]."(".$tmp["username"].")";
|
||
$content[$count][]="<input type=\"checkbox\" id=\"cb".$count."\" name=\"id[]\" value=\"".$msg["id"]."\"><a href=\"".$_SERVER[PHP_SELF]."?_m=".$_m."&_cid=".$_cid."&_a=add&id=".$msg["id"]."\">".$msg["no"]."</a>";
|
||
$content[$count][]=$msg["color"]."-".get_cate_title_no("color",$msg["color"]);
|
||
if($bx_sizegroup_id>0 || $child_sizegroup_id>0)
|
||
$content[$count][]=$msg["bx"];
|
||
if($is_gg!="n")
|
||
$content[$count][]=get_gg_title($msg["bx"]);
|
||
$num=0;
|
||
$str_size_title="<tr bgcolor='#c0c0c0'>";
|
||
$str_size_num="<tr bgcolor='#ffffff'>";
|
||
$q1="select * from ".$table_pre."size where iid='".$msg["size_group_id"]."' order by no";
|
||
$r1=$db->query($q1);
|
||
$tmpn="";
|
||
while($m1=$db->fetch_array($r1)){
|
||
$str_size_title.="<td>".$m1["title"]."</td>";
|
||
$str_size_num.="<td>".deel_0($msg["num_".$m1["no"]])."</td>";
|
||
$num+=$msg["num_".$m1["no"]];
|
||
$tmpn.="{\"v\":\"".$msg["num_".$m1["no"]]."\",\"t\":\"".$m1["title"]."\"},";
|
||
}
|
||
$tmpn=deel_end($tmpn);
|
||
$str_tmp.="\"size\":[".$tmpn."],";
|
||
$content[$count][]=$num;
|
||
$content[$count][]=date("Y-m-d H:i",$msg["add_date"]);
|
||
$str_size_title.="</tr>";
|
||
$str_size_num.="</tr>";
|
||
//$content[$count][]="<table cellspacing=\"1\" cellpadding=\"2\" align=\"center\">".$str_size_title.$str_size_num."</table>";
|
||
|
||
|
||
$str_tmp.="\"num\":\"".$num."\"";
|
||
$count++;
|
||
$str_tmp.="},";
|
||
}
|
||
if(!$content){
|
||
$content[0]="暂无记录!";
|
||
}
|
||
$other_span=($bx_sizegroup_id>0 || $child_sizegroup_id>0)?8:7;
|
||
if($is_gg!="n")
|
||
$other_span++;
|
||
$col_span=$other_span+1;
|
||
$json_data.=substr($str_tmp,0,-1)."],";
|
||
break;
|
||
}
|
||
}
|
||
$json_data=substr($json_data,0,-1)."}";
|
||
echo $json_data;
|
||
?>
|