7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
1174 lines
40 KiB
PHP
1174 lines
40 KiB
PHP
<?php
|
|
//-------------------------------明细
|
|
header("Content-type: text/html; charset=utf-8");
|
|
//-------------------------------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"]);
|
|
|
|
$is_multi_price=get_set("is_multi_price");
|
|
$sys_size_num=get_max_size_num();
|
|
$is_brand=is_brand();
|
|
$zk_type=get_set("zk_type");
|
|
$zb_type=get_set("zb_type");
|
|
$arr_zb_type=explode(",",$zb_type);
|
|
$is_spk=get_set("is_spk");
|
|
//
|
|
$json_data="{";
|
|
if(THIS_IN!="edt_ipad")
|
|
exit("错误的访问!");
|
|
$msg_client=get_db_msg("select * from ".$table_pre."client where id='".$uid."'");
|
|
//
|
|
$face=$msg_client["face"];
|
|
$ph_ms=get_set("ph_ms");
|
|
$arr_ph_ms=explode(",",$ph_ms);
|
|
$sys_size_num=get_max_size_num();
|
|
$json_data.="\"face\":\"".$face."\",";
|
|
|
|
if($s_key){
|
|
if($s_key=="all"){
|
|
$con_f="";
|
|
}else{
|
|
$con_f=" and _key='".$s_key."'";
|
|
}
|
|
$json_data.="\"s_key\":\"".$s_key."\",";
|
|
}
|
|
$is_sy=get_set("is_sy");
|
|
$json_data.="\"username\":\"".$msg_client["username"]."\",";
|
|
$json_data.="\"is_sy\":\"".$is_sy."\",";
|
|
|
|
|
|
switch($face){
|
|
case "1":
|
|
$default_group_by="";
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=9");
|
|
if($tmp["num"]>0){
|
|
$arr_group_by["9"]=d_translate("qy");
|
|
$default_group_by="9";
|
|
}
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=3");
|
|
if($tmp["num"]>0){
|
|
$arr_group_by["3"]=d_translate("dl");
|
|
$default_group_by="3";
|
|
}
|
|
$default_group_by=$default_group_by?$default_group_by:"4";
|
|
|
|
$arr_group_by["4"]="客户";
|
|
$arr_group_by["1"]="明细";
|
|
$s_group_by=$s_group_by?$s_group_by:$default_group_by;
|
|
$msg=get_db_msg("select * from ".$table_pre."kh where no='".$kh."'");
|
|
if($color){
|
|
$pic=get_kh_color_picture($kh,$color);
|
|
}else{
|
|
$pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"]);
|
|
}
|
|
$arr_pic_set=out_good_pic_set_arr($pic,200,200);
|
|
|
|
$json_data.="\"kh\":\"".$msg["no"]."\",";
|
|
$json_data.="\"color\":\"".$color."\",";
|
|
$json_data.="\"pic\":\"".$pic."\",";
|
|
$json_data.="\"pic_w\":\"".$arr_pic_set[0]."\",";
|
|
$json_data.="\"pic_h\":\"".$arr_pic_set[1]."\",";
|
|
$str_group_by="";
|
|
foreach($arr_group_by as $k1 => $v1){
|
|
$str_group_by.="{";
|
|
$str_group_by.="\"group_by_no\":\"".$k1."\",";
|
|
$str_group_by.="\"group_by_title\":\"".$v1."\",";
|
|
if($s_group_by==$k1){
|
|
$str_group_by.="\"group_by_sign\":\"y\"";
|
|
}else{
|
|
$str_group_by.="\"group_by_sign\":\"n\"";
|
|
}
|
|
$str_group_by.="},";
|
|
}
|
|
$json_data.="\"group_by\":[".substr($str_group_by,0,-1)."],";
|
|
|
|
$sql_con="no='".$kh."' and ";
|
|
if($color)
|
|
$sql_con.="color='".$color."' and ";
|
|
$sql_con=substr($sql_con,0,-4);
|
|
if($s_group_by=="1"){
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"client\",\"title\":\"客户\"},";
|
|
$thead_str.="{\"zd\":\"kh\",\"title\":\"款号\"},";
|
|
$thead_str.="{\"zd\":\"color\",\"title\":\"颜色\"},";
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
$thead_str.="{\"zd\":\"bx\",\"title\":\"杯型\"},";
|
|
//
|
|
$size_str="";
|
|
$r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no");
|
|
while($m1=$db->fetch_array($r1)){
|
|
$size_str.=$m1["no"].",";
|
|
}
|
|
if($size_str)
|
|
$size_str=substr($size_str,0,-1);
|
|
$size=explode(",",$size_str);
|
|
}else{
|
|
$size=explode(",",$msg["size"]);
|
|
}
|
|
$tmp1=explode(",",$msg["color"]);
|
|
for($l=0;$l<count($size);$l++){
|
|
$tmp3=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$size[$l]."' limit 0,1");
|
|
$thead_str.="{\"zd\":\"size_".$l."\",\"title\":\"".$tmp3["title"]."\"},";
|
|
}
|
|
$thead_str.="{\"zd\":\"xj\",\"title\":\"小计\"},";
|
|
$thead_str.="{\"zd\":\"order_time\",\"title\":\"订单时间\"}";
|
|
$json_data.="\"thead_str\":[".$thead_str."],";
|
|
|
|
$q="select * from ".$table_pre."order where ".$sql_con.$con_f." order by uid,add_date";
|
|
$r=$db->query($q);
|
|
$hj=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$tmp=get_db_msg("select username,title from ".$table_pre."client where id='".$m["uid"]."'");
|
|
$m_kh=get_db_msg("select no from ".$table_pre."kh where id='".$m["iid"]."'");
|
|
|
|
$tbody_str.="{";
|
|
$tbody_str.="\"client\":\"".$tmp["title"]."(".$tmp["username"].")\",";
|
|
$tbody_str.="\"kh\":\"".$m_kh["no"]."\",";
|
|
$tbody_str.="\"color\":\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\",";
|
|
|
|
if($bx_sizegroup_id==$msg["size_group"])
|
|
$tbody_str.="\"bx\":\"".$m["bx"]."\",";
|
|
//尺码列表
|
|
$xj=0;
|
|
for($l=0;$l<count($size);$l++){
|
|
$xj+=$m["num_".$size[$l]];
|
|
$hj+=$m["num_".$size[$l]];
|
|
//尺码合计
|
|
$v1="hj_".$size[$l];
|
|
$$v1+=$m["num_".$size[$l]];
|
|
$tbody_str.="\"size_".$l."\":\"".$m["num_".$size[$l]]."\",";
|
|
}
|
|
$tbody_str.="\"xj\":\"".$xj."\",";
|
|
$tbody_str.="\"order_time\":\"".date("d日 H点i分",$m["add_date"])."\"";
|
|
$tbody_str.="},";
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
//合计
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
$hj_colspan=4;
|
|
}else{
|
|
$hj_colspan=3;
|
|
}
|
|
|
|
$json_data.="\"tfoot_str\":{\"tdnum\":\"".$hj_colspan."\",";
|
|
for($l=0;$l<count($size);$l++){
|
|
$v1="hj_".$size[$l];
|
|
$json_data.="\"size_".$l."\":\"".$$v1."\",";
|
|
}
|
|
$json_data.="\"xj\":\"".$hj."\",\"order_time\":\" \"";
|
|
$json_data.="},";
|
|
|
|
}else{
|
|
$arr_show_log_hd=array("23"=>"加量","22"=>"减量","24"=>"删单");
|
|
|
|
//取得数组
|
|
$arr1=array();
|
|
$q="select * from ".$table_pre."client where face='".$s_group_by."'";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
if($s_group_by=="4"){
|
|
$tmp_sql=" and uid='".$m["id"]."'";
|
|
}else{
|
|
$p=$m["path"]."-".$m["id"];
|
|
$tmp_sql=" and upath like '".$p."-%'";
|
|
}
|
|
$tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where ".$sql_con.$tmp_sql.$con_f);
|
|
//if($tmp["num"]>0)
|
|
$arr1[$m["id"]]=$tmp["num"];
|
|
}
|
|
arsort($arr1);
|
|
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
//
|
|
$size_str="";
|
|
$r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no");
|
|
while($m1=$db->fetch_array($r1)){
|
|
$size_str.=$m1["no"].",";
|
|
}
|
|
if($size_str)
|
|
$size_str=substr($size_str,0,-1);
|
|
$size=explode(",",$size_str);
|
|
}else{
|
|
$size=explode(",",$msg["size"]);
|
|
}
|
|
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"ct\",\"title\":\"序号\"},";
|
|
$thead_str.="{\"zd\":\"client\",\"title\":\"客户\"},";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
$thead_str.="{\"zd\":\"zd_".$k1."\",\"title\":\"".$v1."<br>次数\"},";
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$tmp3=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$size[$l]."' limit 0,1");
|
|
$thead_str.="{\"zd\":\"size_".$l."\",\"title\":\"".$tmp3["title"]."\"},";
|
|
}
|
|
$thead_str.="{\"zd\":\"xj\",\"title\":\"小计\"}";
|
|
$json_data.="\"thead_str\":[".$thead_str."],";
|
|
|
|
$hj=0;
|
|
$list=1;
|
|
$tbody_str="";
|
|
foreach($arr1 as $id1 => $num1){
|
|
$hj+=$num1;
|
|
$m=get_db_msg("select * from ".$table_pre."client where id='".$id1."'");
|
|
if($s_group_by=="4"){
|
|
$tmp_sql=" and uid='".$m["id"]."'";
|
|
}else{
|
|
$p=$m["path"]."-".$m["id"];
|
|
$tmp_sql=" and (upath='".$p."' or upath like '".$p."-%')";
|
|
}
|
|
$tmp=get_db_msg("select ".get_size_sql("sum1")." from ".$table_pre."order where ".$sql_con.$tmp_sql.$con_f);
|
|
|
|
$tbody_str.="{";
|
|
$tbody_str.="\"ct\":\"".$list."\",";
|
|
$tbody_str.="\"client\":\"".$m["title"]."(".$m["username"].")\",";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
//加单次数
|
|
$t1=get_db_msg("select count(*) 'num' from ".$table_pre."log_hd where uid='".$m["id"]."' and iid='".$msg["id"]."' and action='".$k1."'");
|
|
$tbody_str.="\"zd_".$k1."\":\"".deel_0($t1["num"])."\",";
|
|
$v1="hj_action_".$k1;
|
|
$$v1+=$t1["num"];
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$tbody_str.="\"size_".$l."\":\"".$tmp["num_".$size[$l]]."\",";
|
|
//尺码合计
|
|
$v1="hj_".$size[$l];
|
|
$$v1+=$tmp["num_".$size[$l]];
|
|
}
|
|
$tbody_str.="\"xj\":\"".$num1."\"";
|
|
$tbody_str.="},";
|
|
$list++;
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
$tdnum=2;
|
|
$json_data.="\"tfoot_str\":{\"tdnum\":\"".$tdnum."\",";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
$v1="hj_action_".$k1;
|
|
$json_data.="\"zd_".$k1."\":\"".$$v1."\",";
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$v1="hj_".$size[$l];
|
|
$json_data.="\"size_".$l."\":\"".$$v1."\",";
|
|
}
|
|
$json_data.="\"xj\":\"".$hj."\"";
|
|
$json_data.="},";
|
|
}
|
|
break;
|
|
case "2":
|
|
$cou_u_all=get_qj_ucon_all($msg_client["charge_path_real"]);
|
|
$default_group_by="";
|
|
$default_group_by=$default_group_by?$default_group_by:"4";
|
|
$s_uid="_ALL_";
|
|
if($s_uid){
|
|
if($s_uid=="_ALL_"){
|
|
$sql_con_u=$cou_u_all;
|
|
}else{
|
|
$tmp=get_db_msg("select id,path from ".$table_pre."client where id='".$s_uid."'");
|
|
$tmp_p=$tmp["path"]."-".$tmp["id"];
|
|
$sql_con_u=" and (upath='".$tmp_p."' or upath like '".$tmp_p."-%')";
|
|
}
|
|
}else{
|
|
$sql_con_u=" and uid=0";
|
|
}
|
|
$arr_group_by["4"]="客户";
|
|
$arr_group_by["1"]="明细";
|
|
$s_group_by=$s_group_by?$s_group_by:$default_group_by;
|
|
$msg=get_db_msg("select * from ".$table_pre."kh where no='".$kh."'");
|
|
if($color){
|
|
$pic=get_kh_color_picture($kh,$color);
|
|
}else{
|
|
$pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"]);
|
|
}
|
|
$arr_pic_set=out_good_pic_set_arr($pic,200,200);
|
|
|
|
$json_data.="\"kh\":\"".$msg["no"]."\",";
|
|
$json_data.="\"color\":\"".$color."\",";
|
|
$json_data.="\"pic\":\"".$pic."\",";
|
|
$json_data.="\"pic_w\":\"".$arr_pic_set[0]."\",";
|
|
$json_data.="\"pic_h\":\"".$arr_pic_set[1]."\",";
|
|
$str_group_by="";
|
|
foreach($arr_group_by as $k1 => $v1){
|
|
$str_group_by.="{";
|
|
$str_group_by.="\"group_by_no\":\"".$k1."\",";
|
|
$str_group_by.="\"group_by_title\":\"".$v1."\",";
|
|
if($s_group_by==$k1){
|
|
$str_group_by.="\"group_by_sign\":\"y\"";
|
|
}else{
|
|
$str_group_by.="\"group_by_sign\":\"n\"";
|
|
}
|
|
$str_group_by.="},";
|
|
}
|
|
$json_data.="\"group_by\":[".substr($str_group_by,0,-1)."],";
|
|
|
|
$sql_con="and no='".$kh."' and ";
|
|
if($color)
|
|
$sql_con.="color='".$color."' and ";
|
|
$sql_con=substr($sql_con,0,-4);
|
|
|
|
if($s_group_by=="1"){
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"client\",\"title\":\"客户\"},";
|
|
$thead_str.="{\"zd\":\"kh\",\"title\":\"款号\"},";
|
|
$thead_str.="{\"zd\":\"color\",\"title\":\"颜色\"},";
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
$thead_str.="{\"zd\":\"bx\",\"title\":\"杯型\"},";
|
|
//
|
|
$size_str="";
|
|
$r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no");
|
|
while($m1=$db->fetch_array($r1)){
|
|
$size_str.=$m1["no"].",";
|
|
}
|
|
if($size_str)
|
|
$size_str=substr($size_str,0,-1);
|
|
$size=explode(",",$size_str);
|
|
}else{
|
|
$size=explode(",",$msg["size"]);
|
|
}
|
|
$tmp1=explode(",",$msg["color"]);
|
|
for($l=0;$l<count($size);$l++){
|
|
$tmp3=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$size[$l]."' limit 0,1");
|
|
$thead_str.="{\"zd\":\"size_".$l."\",\"title\":\"".$tmp3["title"]."\"},";
|
|
}
|
|
$thead_str.="{\"zd\":\"xj\",\"title\":\"小计\"},";
|
|
$thead_str.="{\"zd\":\"order_time\",\"title\":\"订单时间\"}";
|
|
$json_data.="\"thead_str\":[".$thead_str."],";
|
|
|
|
$q="select * from ".$table_pre."order where id<>'0'".$sql_con."".$sql_con_u.$con_f." order by uid,add_date";
|
|
$r=$db->query($q);
|
|
$hj=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$tmp=get_db_msg("select username,title from ".$table_pre."client where id='".$m["uid"]."'");
|
|
$m_kh=get_db_msg("select no from ".$table_pre."kh where id='".$m["iid"]."'");
|
|
|
|
$tbody_str.="{";
|
|
$tbody_str.="\"client\":\"".$tmp["title"]."(".$tmp["username"].")\",";
|
|
$tbody_str.="\"kh\":\"".$m_kh["no"]."\",";
|
|
$tbody_str.="\"color\":\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\",";
|
|
|
|
if($bx_sizegroup_id==$msg["size_group"])
|
|
$tbody_str.="\"bx\":\"".$m["bx"]."\",";
|
|
//尺码列表
|
|
$xj=0;
|
|
for($l=0;$l<count($size);$l++){
|
|
$xj+=$m["num_".$size[$l]];
|
|
$hj+=$m["num_".$size[$l]];
|
|
//尺码合计
|
|
$v1="hj_".$size[$l];
|
|
$$v1+=$m["num_".$size[$l]];
|
|
$tbody_str.="\"size_".$l."\":\"".$m["num_".$size[$l]]."\",";
|
|
}
|
|
$tbody_str.="\"xj\":\"".$xj."\",";
|
|
$tbody_str.="\"order_time\":\"".date("d日 H点i分",$m["add_date"])."\"";
|
|
$tbody_str.="},";
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
//合计
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
$hj_colspan=4;
|
|
}else{
|
|
$hj_colspan=3;
|
|
}
|
|
|
|
$json_data.="\"tfoot_str\":{\"tdnum\":\"".$hj_colspan."\",";
|
|
for($l=0;$l<count($size);$l++){
|
|
$v1="hj_".$size[$l];
|
|
$json_data.="\"size_".$l."\":\"".$$v1."\",";
|
|
}
|
|
$json_data.="\"xj\":\"".$hj."\",\"order_time\":\" \"";
|
|
$json_data.="},";
|
|
|
|
}else{
|
|
$arr_show_log_hd=array("23"=>"加量","22"=>"减量","24"=>"删单");
|
|
|
|
//取得数组
|
|
$arr1=array();
|
|
$q="select * from (select id,face,concat(path,'-',id) 'upath' from ".$table_pre."client where face='4') a where a.id>0 ".$sql_con_u;
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
if($s_group_by=="4"){
|
|
$tmp_sql=" and uid='".$m["id"]."'";
|
|
}else{
|
|
$p=$m["path"]."-".$m["id"];
|
|
$tmp_sql=" and upath like '".$p."-%'";
|
|
}
|
|
$tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where id>'0' ".$sql_con.$tmp_sql.$con_f);
|
|
//if($tmp["num"]>0)
|
|
$arr1[$m["id"]]=$tmp["num"];
|
|
}
|
|
arsort($arr1);
|
|
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
//
|
|
$size_str="";
|
|
$r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no");
|
|
while($m1=$db->fetch_array($r1)){
|
|
$size_str.=$m1["no"].",";
|
|
}
|
|
if($size_str)
|
|
$size_str=substr($size_str,0,-1);
|
|
$size=explode(",",$size_str);
|
|
}else{
|
|
$size=explode(",",$msg["size"]);
|
|
}
|
|
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"ct\",\"title\":\"序号\"},";
|
|
$thead_str.="{\"zd\":\"client\",\"title\":\"客户\"},";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
$thead_str.="{\"zd\":\"zd_".$k1."\",\"title\":\"".$v1."<br>次数\"},";
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$tmp3=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$size[$l]."' limit 0,1");
|
|
$thead_str.="{\"zd\":\"size_".$l."\",\"title\":\"".$tmp3["title"]."\"},";
|
|
}
|
|
$thead_str.="{\"zd\":\"xj\",\"title\":\"小计\"}";
|
|
$json_data.="\"thead_str\":[".$thead_str."],";
|
|
|
|
$hj=0;
|
|
$list=1;
|
|
$tbody_str="";
|
|
foreach($arr1 as $id1 => $num1){
|
|
$hj+=$num1;
|
|
$m=get_db_msg("select * from ".$table_pre."client where id='".$id1."'");
|
|
if($s_group_by=="4"){
|
|
$tmp_sql=" and uid='".$m["id"]."'";
|
|
}else{
|
|
$p=$m["path"]."-".$m["id"];
|
|
$tmp_sql=" and (upath='".$p."' or upath like '".$p."-%')";
|
|
}
|
|
$tmp=get_db_msg("select ".get_size_sql("sum1")." from ".$table_pre."order where id>'0' ".$sql_con.$tmp_sql.$con_f);
|
|
$tbody_str.="{";
|
|
$tbody_str.="\"ct\":\"".$list."\",";
|
|
$tbody_str.="\"client\":\"".$m["title"]."(".$m["username"].")\",";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
//加单次数
|
|
$t1=get_db_msg("select count(*) 'num' from ".$table_pre."log_hd where uid='".$m["id"]."' and iid='".$msg["id"]."' and action='".$k1."'");
|
|
$tbody_str.="\"zd_".$k1."\":\"".deel_0($t1["num"])."\",";
|
|
$v1="hj_action_".$k1;
|
|
$$v1+=$t1["num"];
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$tbody_str.="\"size_".$l."\":\"".$tmp["num_".$size[$l]]."\",";
|
|
//尺码合计
|
|
$v1="hj_".$size[$l];
|
|
$$v1+=$tmp["num_".$size[$l]];
|
|
}
|
|
$tbody_str.="\"xj\":\"".$num1."\"";
|
|
$tbody_str.="},";
|
|
$list++;
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
$tdnum=2;
|
|
$json_data.="\"tfoot_str\":{\"tdnum\":\"".$tdnum."\",";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
$v1="hj_action_".$k1;
|
|
$json_data.="\"zd_".$k1."\":\"".$$v1."\",";
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$v1="hj_".$size[$l];
|
|
$json_data.="\"size_".$l."\":\"".$$v1."\",";
|
|
}
|
|
$json_data.="\"xj\":\"".$hj."\"";
|
|
$json_data.="},";
|
|
}
|
|
break;
|
|
case "3":
|
|
$p=$msg_client["path"]."-".$msg_client["id"];
|
|
$cou_u_all=" and (upath='".$p."' or upath like '".$p."-%')";
|
|
if($s_uid){
|
|
$tmp=get_db_msg("select id,path from ".$table_pre."client where id='".$s_uid."'");
|
|
$tmp_p=$tmp["path"]."-".$tmp["id"];
|
|
$sql_con_u=" and (upath='".$tmp_p."' or upath like '".$tmp_p."-%')";
|
|
}else{
|
|
$sql_con_u=$cou_u_all;
|
|
}
|
|
$default_group_by="4";
|
|
$arr_group_by["4"]="客户";
|
|
$arr_group_by["1"]="明细";
|
|
$s_group_by=$s_group_by?$s_group_by:$default_group_by;
|
|
$msg=get_db_msg("select * from ".$table_pre."kh where no='".$kh."'");
|
|
if($color){
|
|
$pic=get_kh_color_picture($kh,$color);
|
|
}else{
|
|
$pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"]);
|
|
}
|
|
$arr_pic_set=out_good_pic_set_arr($pic,200,200);
|
|
$json_data.="\"kh\":\"".$msg["no"]."\",";
|
|
$json_data.="\"color\":\"".$color."\",";
|
|
$json_data.="\"pic\":\"".$pic."\",";
|
|
$json_data.="\"pic_w\":\"".$arr_pic_set[0]."\",";
|
|
$json_data.="\"pic_h\":\"".$arr_pic_set[1]."\",";
|
|
$str_group_by="";
|
|
foreach($arr_group_by as $k1 => $v1){
|
|
$str_group_by.="{";
|
|
$str_group_by.="\"group_by_no\":\"".$k1."\",";
|
|
$str_group_by.="\"group_by_title\":\"".$v1."\",";
|
|
if($s_group_by==$k1){
|
|
$str_group_by.="\"group_by_sign\":\"y\"";
|
|
}else{
|
|
$str_group_by.="\"group_by_sign\":\"n\"";
|
|
}
|
|
$str_group_by.="},";
|
|
}
|
|
$json_data.="\"group_by\":[".substr($str_group_by,0,-1)."],";
|
|
|
|
$sql_con=" and no='".$kh."' and ";
|
|
if($color)
|
|
$sql_con.="color='".$color."' and ";
|
|
$sql_con=substr($sql_con,0,-4);
|
|
if($s_group_by=="1"){
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"client\",\"title\":\"客户\"},";
|
|
$thead_str.="{\"zd\":\"kh\",\"title\":\"款号\"},";
|
|
$thead_str.="{\"zd\":\"color\",\"title\":\"颜色\"},";
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
$thead_str.="{\"zd\":\"bx\",\"title\":\"杯型\"},";
|
|
//
|
|
$size_str="";
|
|
$r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no");
|
|
while($m1=$db->fetch_array($r1)){
|
|
$size_str.=$m1["no"].",";
|
|
}
|
|
if($size_str)
|
|
$size_str=substr($size_str,0,-1);
|
|
$size=explode(",",$size_str);
|
|
}else{
|
|
$size=explode(",",$msg["size"]);
|
|
}
|
|
$tmp1=explode(",",$msg["color"]);
|
|
for($l=0;$l<count($size);$l++){
|
|
$tmp3=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$size[$l]."' limit 0,1");
|
|
$thead_str.="{\"zd\":\"size_".$l."\",\"title\":\"".$tmp3["title"]."\"},";
|
|
}
|
|
$thead_str.="{\"zd\":\"xj\",\"title\":\"小计\"},";
|
|
$thead_str.="{\"zd\":\"order_time\",\"title\":\"订单时间\"}";
|
|
$json_data.="\"thead_str\":[".$thead_str."],";
|
|
|
|
$q="select * from ".$table_pre."order where id>'0' ".$sql_con."".$sql_con_u.$con_f." order by uid,add_date";
|
|
$r=$db->query($q);
|
|
$hj=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$tmp=get_db_msg("select username,title from ".$table_pre."client where id='".$m["uid"]."'");
|
|
$m_kh=get_db_msg("select no from ".$table_pre."kh where id='".$m["iid"]."'");
|
|
|
|
$tbody_str.="{";
|
|
$tbody_str.="\"client\":\"".$tmp["title"]."(".$tmp["username"].")\",";
|
|
$tbody_str.="\"kh\":\"".$m_kh["no"]."\",";
|
|
$tbody_str.="\"color\":\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\",";
|
|
|
|
if($bx_sizegroup_id==$msg["size_group"])
|
|
$tbody_str.="\"bx\":\"".$m["bx"]."\",";
|
|
//尺码列表
|
|
$xj=0;
|
|
for($l=0;$l<count($size);$l++){
|
|
$xj+=$m["num_".$size[$l]];
|
|
$hj+=$m["num_".$size[$l]];
|
|
//尺码合计
|
|
$v1="hj_".$size[$l];
|
|
$$v1+=$m["num_".$size[$l]];
|
|
$tbody_str.="\"size_".$l."\":\"".$m["num_".$size[$l]]."\",";
|
|
}
|
|
$tbody_str.="\"xj\":\"".$xj."\",";
|
|
$tbody_str.="\"order_time\":\"".date("d日 H点i分",$m["add_date"])."\"";
|
|
$tbody_str.="},";
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
//合计
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
$hj_colspan=4;
|
|
}else{
|
|
$hj_colspan=3;
|
|
}
|
|
|
|
$json_data.="\"tfoot_str\":{\"tdnum\":\"".$hj_colspan."\",";
|
|
for($l=0;$l<count($size);$l++){
|
|
$v1="hj_".$size[$l];
|
|
$json_data.="\"size_".$l."\":\"".$$v1."\",";
|
|
}
|
|
$json_data.="\"xj\":\"".$hj."\",\"order_time\":\" \"";
|
|
$json_data.="},";
|
|
|
|
}else{
|
|
$arr_show_log_hd=array("23"=>"加量","22"=>"减量","24"=>"删单");
|
|
|
|
//取得数组
|
|
$arr1=array();
|
|
$q="select * from (select id,face,concat(path,'-',id) 'upath' from ".$table_pre."client where face='4') a where a.id>0 ".$sql_con_u;
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
if($s_group_by=="4"){
|
|
$tmp_sql=" and uid='".$m["id"]."'";
|
|
}else{
|
|
$p=$m["path"]."-".$m["id"];
|
|
$tmp_sql=" and upath like '".$p."-%'";
|
|
}
|
|
$tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where id>0 ".$sql_con.$tmp_sql.$con_f);
|
|
//if($tmp["num"]>0)
|
|
$arr1[$m["id"]]=$tmp["num"];
|
|
}
|
|
arsort($arr1);
|
|
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
//
|
|
$size_str="";
|
|
$r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no");
|
|
while($m1=$db->fetch_array($r1)){
|
|
$size_str.=$m1["no"].",";
|
|
}
|
|
if($size_str)
|
|
$size_str=substr($size_str,0,-1);
|
|
$size=explode(",",$size_str);
|
|
}else{
|
|
$size=explode(",",$msg["size"]);
|
|
}
|
|
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"ct\",\"title\":\"序号\"},";
|
|
$thead_str.="{\"zd\":\"client\",\"title\":\"客户\"},";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
$thead_str.="{\"zd\":\"zd_".$k1."\",\"title\":\"".$v1."<br>次数\"},";
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$tmp3=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$size[$l]."' limit 0,1");
|
|
$thead_str.="{\"zd\":\"size_".$l."\",\"title\":\"".$tmp3["title"]."\"},";
|
|
}
|
|
$thead_str.="{\"zd\":\"xj\",\"title\":\"小计\"}";
|
|
$json_data.="\"thead_str\":[".$thead_str."],";
|
|
|
|
$hj=0;
|
|
$list=1;
|
|
$tbody_str="";
|
|
foreach($arr1 as $id1 => $num1){
|
|
$hj+=$num1;
|
|
$m=get_db_msg("select * from ".$table_pre."client where id='".$id1."'");
|
|
if($s_group_by=="4"){
|
|
$tmp_sql=" and uid='".$m["id"]."'";
|
|
}else{
|
|
$p=$m["path"]."-".$m["id"];
|
|
$tmp_sql=" and (upath='".$p."' or upath like '".$p."-%')";
|
|
}
|
|
$tmp=get_db_msg("select ".get_size_sql("sum1")." from ".$table_pre."order where id>'0' ".$sql_con.$tmp_sql.$con_f);
|
|
|
|
$tbody_str.="{";
|
|
$tbody_str.="\"ct\":\"".$list."\",";
|
|
$tbody_str.="\"client\":\"".$m["title"]."(".$m["username"].")\",";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
//加单次数
|
|
$t1=get_db_msg("select count(*) 'num' from ".$table_pre."log_hd where uid='".$m["id"]."' and iid='".$msg["id"]."' and action='".$k1."'");
|
|
$tbody_str.="\"zd_".$k1."\":\"".deel_0($t1["num"])."\",";
|
|
$v1="hj_action_".$k1;
|
|
$$v1+=$t1["num"];
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$tbody_str.="\"size_".$l."\":\"".$tmp["num_".$size[$l]]."\",";
|
|
//尺码合计
|
|
$v1="hj_".$size[$l];
|
|
$$v1+=$tmp["num_".$size[$l]];
|
|
}
|
|
$tbody_str.="\"xj\":\"".$num1."\"";
|
|
$tbody_str.="},";
|
|
$list++;
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
$tdnum=2;
|
|
$json_data.="\"tfoot_str\":{\"tdnum\":\"".$tdnum."\",";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
$v1="hj_action_".$k1;
|
|
$json_data.="\"zd_".$k1."\":\"".$$v1."\",";
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$v1="hj_".$size[$l];
|
|
$json_data.="\"size_".$l."\":\"".$$v1."\",";
|
|
}
|
|
$json_data.="\"xj\":\"".$hj."\"";
|
|
$json_data.="},";
|
|
}
|
|
break;
|
|
case "7":
|
|
$default_group_by="";
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=9");
|
|
if($tmp["num"]>0){
|
|
$arr_group_by["9"]=d_translate("qy");
|
|
$default_group_by="9";
|
|
}
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=3");
|
|
if($tmp["num"]>0){
|
|
$arr_group_by["3"]=d_translate("dl");
|
|
$default_group_by="3";
|
|
}
|
|
$default_group_by=$default_group_by?$default_group_by:"4";
|
|
|
|
$arr_group_by["4"]="客户";
|
|
$arr_group_by["1"]="明细";
|
|
$s_group_by=$s_group_by?$s_group_by:$default_group_by;
|
|
$msg=get_db_msg("select * from ".$table_pre."kh where no='".$kh."'");
|
|
if($color){
|
|
$pic=get_kh_color_picture($kh,$color);
|
|
}else{
|
|
$pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"]);
|
|
}
|
|
$arr_pic_set=out_good_pic_set_arr($pic,200,200);
|
|
|
|
$json_data.="\"kh\":\"".$msg["no"]."\",";
|
|
$json_data.="\"color\":\"".$color."\",";
|
|
$json_data.="\"pic\":\"".$pic."\",";
|
|
$json_data.="\"pic_w\":\"".$arr_pic_set[0]."\",";
|
|
$json_data.="\"pic_h\":\"".$arr_pic_set[1]."\",";
|
|
$str_group_by="";
|
|
foreach($arr_group_by as $k1 => $v1){
|
|
$str_group_by.="{";
|
|
$str_group_by.="\"group_by_no\":\"".$k1."\",";
|
|
$str_group_by.="\"group_by_title\":\"".$v1."\",";
|
|
if($s_group_by==$k1){
|
|
$str_group_by.="\"group_by_sign\":\"y\"";
|
|
}else{
|
|
$str_group_by.="\"group_by_sign\":\"n\"";
|
|
}
|
|
$str_group_by.="},";
|
|
}
|
|
$json_data.="\"group_by\":[".substr($str_group_by,0,-1)."],";
|
|
|
|
$sql_con="no='".$kh."' and ";
|
|
if($color)
|
|
$sql_con.="color='".$color."' and ";
|
|
$sql_con=substr($sql_con,0,-4);
|
|
if($s_group_by=="1"){
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"client\",\"title\":\"客户\"},";
|
|
$thead_str.="{\"zd\":\"kh\",\"title\":\"款号\"},";
|
|
$thead_str.="{\"zd\":\"color\",\"title\":\"颜色\"},";
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
$thead_str.="{\"zd\":\"bx\",\"title\":\"杯型\"},";
|
|
//
|
|
$size_str="";
|
|
$r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no");
|
|
while($m1=$db->fetch_array($r1)){
|
|
$size_str.=$m1["no"].",";
|
|
}
|
|
if($size_str)
|
|
$size_str=substr($size_str,0,-1);
|
|
$size=explode(",",$size_str);
|
|
}else{
|
|
$size=explode(",",$msg["size"]);
|
|
}
|
|
$tmp1=explode(",",$msg["color"]);
|
|
for($l=0;$l<count($size);$l++){
|
|
$tmp3=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$size[$l]."' limit 0,1");
|
|
$thead_str.="{\"zd\":\"size_".$l."\",\"title\":\"".$tmp3["title"]."\"},";
|
|
}
|
|
$thead_str.="{\"zd\":\"xj\",\"title\":\"小计\"},";
|
|
$thead_str.="{\"zd\":\"order_time\",\"title\":\"订单时间\"}";
|
|
$json_data.="\"thead_str\":[".$thead_str."],";
|
|
|
|
$q="select * from ".$table_pre."order where ".$sql_con.$con_f." order by uid,add_date";
|
|
$r=$db->query($q);
|
|
$hj=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$tmp=get_db_msg("select username,title from ".$table_pre."client where id='".$m["uid"]."'");
|
|
$m_kh=get_db_msg("select no from ".$table_pre."kh where id='".$m["iid"]."'");
|
|
|
|
$tbody_str.="{";
|
|
$tbody_str.="\"client\":\"".$tmp["title"]."(".$tmp["username"].")\",";
|
|
$tbody_str.="\"kh\":\"".$m_kh["no"]."\",";
|
|
$tbody_str.="\"color\":\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\",";
|
|
|
|
if($bx_sizegroup_id==$msg["size_group"])
|
|
$tbody_str.="\"bx\":\"".$m["bx"]."\",";
|
|
//尺码列表
|
|
$xj=0;
|
|
for($l=0;$l<count($size);$l++){
|
|
$xj+=$m["num_".$size[$l]];
|
|
$hj+=$m["num_".$size[$l]];
|
|
//尺码合计
|
|
$v1="hj_".$size[$l];
|
|
$$v1+=$m["num_".$size[$l]];
|
|
$tbody_str.="\"size_".$l."\":\"".$m["num_".$size[$l]]."\",";
|
|
}
|
|
$tbody_str.="\"xj\":\"".$xj."\",";
|
|
$tbody_str.="\"order_time\":\"".date("d日 H点i分",$m["add_date"])."\"";
|
|
$tbody_str.="},";
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
//合计
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
$hj_colspan=4;
|
|
}else{
|
|
$hj_colspan=3;
|
|
}
|
|
|
|
$json_data.="\"tfoot_str\":{\"tdnum\":\"".$hj_colspan."\",";
|
|
for($l=0;$l<count($size);$l++){
|
|
$v1="hj_".$size[$l];
|
|
$json_data.="\"size_".$l."\":\"".$$v1."\",";
|
|
}
|
|
$json_data.="\"xj\":\"".$hj."\",\"order_time\":\" \"";
|
|
$json_data.="},";
|
|
|
|
}else{
|
|
$arr_show_log_hd=array("23"=>"加量","22"=>"减量","24"=>"删单");
|
|
|
|
//取得数组
|
|
$arr1=array();
|
|
$q="select * from ".$table_pre."client where face='".$s_group_by."'";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
if($s_group_by=="4"){
|
|
$tmp_sql=" and uid='".$m["id"]."'";
|
|
}else{
|
|
$p=$m["path"]."-".$m["id"];
|
|
$tmp_sql=" and upath like '".$p."-%'";
|
|
}
|
|
$tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where ".$sql_con.$tmp_sql.$con_f);
|
|
//if($tmp["num"]>0)
|
|
$arr1[$m["id"]]=$tmp["num"];
|
|
}
|
|
arsort($arr1);
|
|
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
//
|
|
$size_str="";
|
|
$r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no");
|
|
while($m1=$db->fetch_array($r1)){
|
|
$size_str.=$m1["no"].",";
|
|
}
|
|
if($size_str)
|
|
$size_str=substr($size_str,0,-1);
|
|
$size=explode(",",$size_str);
|
|
}else{
|
|
$size=explode(",",$msg["size"]);
|
|
}
|
|
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"ct\",\"title\":\"序号\"},";
|
|
$thead_str.="{\"zd\":\"client\",\"title\":\"客户\"},";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
$thead_str.="{\"zd\":\"zd_".$k1."\",\"title\":\"".$v1."<br>次数\"},";
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$tmp3=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$size[$l]."' limit 0,1");
|
|
$thead_str.="{\"zd\":\"size_".$l."\",\"title\":\"".$tmp3["title"]."\"},";
|
|
}
|
|
$thead_str.="{\"zd\":\"xj\",\"title\":\"小计\"}";
|
|
$json_data.="\"thead_str\":[".$thead_str."],";
|
|
|
|
$hj=0;
|
|
$list=1;
|
|
$tbody_str="";
|
|
foreach($arr1 as $id1 => $num1){
|
|
$hj+=$num1;
|
|
$m=get_db_msg("select * from ".$table_pre."client where id='".$id1."'");
|
|
if($s_group_by=="4"){
|
|
$tmp_sql=" and uid='".$m["id"]."'";
|
|
}else{
|
|
$p=$m["path"]."-".$m["id"];
|
|
$tmp_sql=" and (upath='".$p."' or upath like '".$p."-%')";
|
|
}
|
|
$tmp=get_db_msg("select ".get_size_sql("sum1")." from ".$table_pre."order where ".$sql_con.$tmp_sql.$con_f);
|
|
|
|
$tbody_str.="{";
|
|
$tbody_str.="\"ct\":\"".$list."\",";
|
|
$tbody_str.="\"client\":\"".$m["title"]."(".$m["username"].")\",";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
//加单次数
|
|
$t1=get_db_msg("select count(*) 'num' from ".$table_pre."log_hd where uid='".$m["id"]."' and iid='".$msg["id"]."' and action='".$k1."'");
|
|
$tbody_str.="\"zd_".$k1."\":\"".deel_0($t1["num"])."\",";
|
|
$v1="hj_action_".$k1;
|
|
$$v1+=$t1["num"];
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$tbody_str.="\"size_".$l."\":\"".$tmp["num_".$size[$l]]."\",";
|
|
//尺码合计
|
|
$v1="hj_".$size[$l];
|
|
$$v1+=$tmp["num_".$size[$l]];
|
|
}
|
|
$tbody_str.="\"xj\":\"".$num1."\"";
|
|
$tbody_str.="},";
|
|
$list++;
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
$tdnum=2;
|
|
$json_data.="\"tfoot_str\":{\"tdnum\":\"".$tdnum."\",";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
$v1="hj_action_".$k1;
|
|
$json_data.="\"zd_".$k1."\":\"".$$v1."\",";
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$v1="hj_".$size[$l];
|
|
$json_data.="\"size_".$l."\":\"".$$v1."\",";
|
|
}
|
|
$json_data.="\"xj\":\"".$hj."\"";
|
|
$json_data.="},";
|
|
}
|
|
break;
|
|
case "11":
|
|
$default_group_by="";
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=9");
|
|
if($tmp["num"]>0){
|
|
$arr_group_by["9"]=d_translate("qy");
|
|
$default_group_by="9";
|
|
}
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=3");
|
|
if($tmp["num"]>0){
|
|
$arr_group_by["3"]=d_translate("dl");
|
|
$default_group_by="3";
|
|
}
|
|
$default_group_by=$default_group_by?$default_group_by:"4";
|
|
|
|
$arr_group_by["4"]="客户";
|
|
$arr_group_by["1"]="明细";
|
|
$s_group_by=$s_group_by?$s_group_by:$default_group_by;
|
|
$msg=get_db_msg("select * from ".$table_pre."kh where no='".$kh."'");
|
|
if($color){
|
|
$pic=get_kh_color_picture($kh,$color);
|
|
}else{
|
|
$pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"]);
|
|
}
|
|
$arr_pic_set=out_good_pic_set_arr($pic,200,200);
|
|
|
|
$json_data.="\"kh\":\"".$msg["no"]."\",";
|
|
$json_data.="\"color\":\"".$color."\",";
|
|
$json_data.="\"pic\":\"".$pic."\",";
|
|
$json_data.="\"pic_w\":\"".$arr_pic_set[0]."\",";
|
|
$json_data.="\"pic_h\":\"".$arr_pic_set[1]."\",";
|
|
$str_group_by="";
|
|
foreach($arr_group_by as $k1 => $v1){
|
|
$str_group_by.="{";
|
|
$str_group_by.="\"group_by_no\":\"".$k1."\",";
|
|
$str_group_by.="\"group_by_title\":\"".$v1."\",";
|
|
if($s_group_by==$k1){
|
|
$str_group_by.="\"group_by_sign\":\"y\"";
|
|
}else{
|
|
$str_group_by.="\"group_by_sign\":\"n\"";
|
|
}
|
|
$str_group_by.="},";
|
|
}
|
|
$json_data.="\"group_by\":[".substr($str_group_by,0,-1)."],";
|
|
|
|
$sql_con="no='".$kh."' and ";
|
|
if($color)
|
|
$sql_con.="color='".$color."' and ";
|
|
$sql_con=substr($sql_con,0,-4);
|
|
if($s_group_by=="1"){
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"client\",\"title\":\"客户\"},";
|
|
$thead_str.="{\"zd\":\"kh\",\"title\":\"款号\"},";
|
|
$thead_str.="{\"zd\":\"color\",\"title\":\"颜色\"},";
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
$thead_str.="{\"zd\":\"bx\",\"title\":\"杯型\"},";
|
|
//
|
|
$size_str="";
|
|
$r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no");
|
|
while($m1=$db->fetch_array($r1)){
|
|
$size_str.=$m1["no"].",";
|
|
}
|
|
if($size_str)
|
|
$size_str=substr($size_str,0,-1);
|
|
$size=explode(",",$size_str);
|
|
}else{
|
|
$size=explode(",",$msg["size"]);
|
|
}
|
|
$tmp1=explode(",",$msg["color"]);
|
|
for($l=0;$l<count($size);$l++){
|
|
$tmp3=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$size[$l]."' limit 0,1");
|
|
$thead_str.="{\"zd\":\"size_".$l."\",\"title\":\"".$tmp3["title"]."\"},";
|
|
}
|
|
$thead_str.="{\"zd\":\"xj\",\"title\":\"小计\"},";
|
|
$thead_str.="{\"zd\":\"order_time\",\"title\":\"订单时间\"}";
|
|
$json_data.="\"thead_str\":[".$thead_str."],";
|
|
|
|
$q="select * from ".$table_pre."order where ".$sql_con.$con_f." order by uid,add_date";
|
|
$r=$db->query($q);
|
|
$hj=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$tmp=get_db_msg("select username,title from ".$table_pre."client where id='".$m["uid"]."'");
|
|
$m_kh=get_db_msg("select no from ".$table_pre."kh where id='".$m["iid"]."'");
|
|
|
|
$tbody_str.="{";
|
|
$tbody_str.="\"client\":\"".$tmp["title"]."(".$tmp["username"].")\",";
|
|
$tbody_str.="\"kh\":\"".$m_kh["no"]."\",";
|
|
$tbody_str.="\"color\":\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\",";
|
|
|
|
if($bx_sizegroup_id==$msg["size_group"])
|
|
$tbody_str.="\"bx\":\"".$m["bx"]."\",";
|
|
//尺码列表
|
|
$xj=0;
|
|
for($l=0;$l<count($size);$l++){
|
|
$xj+=$m["num_".$size[$l]];
|
|
$hj+=$m["num_".$size[$l]];
|
|
//尺码合计
|
|
$v1="hj_".$size[$l];
|
|
$$v1+=$m["num_".$size[$l]];
|
|
$tbody_str.="\"size_".$l."\":\"".$m["num_".$size[$l]]."\",";
|
|
}
|
|
$tbody_str.="\"xj\":\"".$xj."\",";
|
|
$tbody_str.="\"order_time\":\"".date("d日 H点i分",$m["add_date"])."\"";
|
|
$tbody_str.="},";
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
//合计
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
$hj_colspan=4;
|
|
}else{
|
|
$hj_colspan=3;
|
|
}
|
|
|
|
$json_data.="\"tfoot_str\":{\"tdnum\":\"".$hj_colspan."\",";
|
|
for($l=0;$l<count($size);$l++){
|
|
$v1="hj_".$size[$l];
|
|
$json_data.="\"size_".$l."\":\"".$$v1."\",";
|
|
}
|
|
$json_data.="\"xj\":\"".$hj."\",\"order_time\":\" \"";
|
|
$json_data.="},";
|
|
|
|
}else{
|
|
$arr_show_log_hd=array("23"=>"加量","22"=>"减量","24"=>"删单");
|
|
|
|
//取得数组
|
|
$arr1=array();
|
|
$q="select * from ".$table_pre."client where face='".$s_group_by."'";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
if($s_group_by=="4"){
|
|
$tmp_sql=" and uid='".$m["id"]."'";
|
|
}else{
|
|
$p=$m["path"]."-".$m["id"];
|
|
$tmp_sql=" and upath like '".$p."-%'";
|
|
}
|
|
$tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where ".$sql_con.$tmp_sql.$con_f);
|
|
//if($tmp["num"]>0)
|
|
$arr1[$m["id"]]=$tmp["num"];
|
|
}
|
|
arsort($arr1);
|
|
|
|
if($bx_sizegroup_id==$msg["size_group"]){
|
|
//
|
|
$size_str="";
|
|
$r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no");
|
|
while($m1=$db->fetch_array($r1)){
|
|
$size_str.=$m1["no"].",";
|
|
}
|
|
if($size_str)
|
|
$size_str=substr($size_str,0,-1);
|
|
$size=explode(",",$size_str);
|
|
}else{
|
|
$size=explode(",",$msg["size"]);
|
|
}
|
|
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"ct\",\"title\":\"序号\"},";
|
|
$thead_str.="{\"zd\":\"client\",\"title\":\"客户\"},";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
$thead_str.="{\"zd\":\"zd_".$k1."\",\"title\":\"".$v1."<br>次数\"},";
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$tmp3=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$size[$l]."' limit 0,1");
|
|
$thead_str.="{\"zd\":\"size_".$l."\",\"title\":\"".$tmp3["title"]."\"},";
|
|
}
|
|
$thead_str.="{\"zd\":\"xj\",\"title\":\"小计\"}";
|
|
$json_data.="\"thead_str\":[".$thead_str."],";
|
|
|
|
$hj=0;
|
|
$list=1;
|
|
$tbody_str="";
|
|
foreach($arr1 as $id1 => $num1){
|
|
$hj+=$num1;
|
|
$m=get_db_msg("select * from ".$table_pre."client where id='".$id1."'");
|
|
if($s_group_by=="4"){
|
|
$tmp_sql=" and uid='".$m["id"]."'";
|
|
}else{
|
|
$p=$m["path"]."-".$m["id"];
|
|
$tmp_sql=" and (upath='".$p."' or upath like '".$p."-%')";
|
|
}
|
|
$tmp=get_db_msg("select ".get_size_sql("sum1")." from ".$table_pre."order where ".$sql_con.$tmp_sql.$con_f);
|
|
|
|
$tbody_str.="{";
|
|
$tbody_str.="\"ct\":\"".$list."\",";
|
|
$tbody_str.="\"client\":\"".$m["title"]."(".$m["username"].")\",";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
//加单次数
|
|
$t1=get_db_msg("select count(*) 'num' from ".$table_pre."log_hd where uid='".$m["id"]."' and iid='".$msg["id"]."' and action='".$k1."'");
|
|
$tbody_str.="\"zd_".$k1."\":\"".deel_0($t1["num"])."\",";
|
|
$v1="hj_action_".$k1;
|
|
$$v1+=$t1["num"];
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$tbody_str.="\"size_".$l."\":\"".$tmp["num_".$size[$l]]."\",";
|
|
//尺码合计
|
|
$v1="hj_".$size[$l];
|
|
$$v1+=$tmp["num_".$size[$l]];
|
|
}
|
|
$tbody_str.="\"xj\":\"".$num1."\"";
|
|
$tbody_str.="},";
|
|
$list++;
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
$tdnum=2;
|
|
$json_data.="\"tfoot_str\":{\"tdnum\":\"".$tdnum."\",";
|
|
|
|
if($s_group_by=="4"){
|
|
foreach($arr_show_log_hd as $k1 => $v1){
|
|
$v1="hj_action_".$k1;
|
|
$json_data.="\"zd_".$k1."\":\"".$$v1."\",";
|
|
}
|
|
}
|
|
for($l=0;$l<count($size);$l++){
|
|
$v1="hj_".$size[$l];
|
|
$json_data.="\"size_".$l."\":\"".$$v1."\",";
|
|
}
|
|
$json_data.="\"xj\":\"".$hj."\"";
|
|
$json_data.="},";
|
|
}
|
|
break;
|
|
}
|
|
$json_data=substr($json_data,0,-1)."}";
|
|
echo $json_data;
|
|
?>
|