7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
363 lines
12 KiB
PHP
363 lines
12 KiB
PHP
<?php
|
||
//-----------------------------------------------------后台->订单打印->明细单
|
||
|
||
//--------------条件定制
|
||
/*
|
||
$arr_zd=array(
|
||
"xh",//圆牌号
|
||
"kh",//款号
|
||
"title",//款式名称
|
||
"brand",
|
||
"series",
|
||
"theme",
|
||
"season",
|
||
"bc",
|
||
"sxz",
|
||
"category",
|
||
"category1",
|
||
"kh_dj",
|
||
"designer",
|
||
"zd1",
|
||
"zd2",
|
||
"zd3",
|
||
"remark",//备注
|
||
"color",//颜色代码
|
||
"color_title",//颜色名称
|
||
"bx",
|
||
"size",//尺码
|
||
"num",//数量
|
||
"dpj",//吊牌价
|
||
"je",//吊牌金额
|
||
"zk",//折扣
|
||
"jsj",//结算价
|
||
"jsje"//结算金额
|
||
);
|
||
*/
|
||
//显示字段
|
||
$arr_zd=array("xh","kh","brand","bc","color","color_title","size","xs","num");
|
||
//排序
|
||
$con_order="no";
|
||
//可筛选字段
|
||
//$search_zd="brand";
|
||
$search_zd="";
|
||
//语言翻译
|
||
$arr_lang=array(
|
||
"title"=>"款式名",
|
||
"color"=>"颜色代码",
|
||
"color_title"=>"颜色",
|
||
"remark"=>"备注",
|
||
"size"=>"尺码明细",
|
||
"dpj"=>"吊牌价",
|
||
"num"=>"小计",
|
||
"xs"=>"箱数",
|
||
"je"=>"吊牌金额",
|
||
"zk"=>"折扣",
|
||
"bx"=>"版型",
|
||
"jsj"=>"结算价",
|
||
"jsje"=>"结算金额"
|
||
);
|
||
//--------------
|
||
$print_not_qr=get_set("print_not_qr");
|
||
$is_brand=get_set("is_brand");
|
||
//查询条件定制
|
||
$s_ka="n";
|
||
$s_key=$_key;
|
||
$con=" and ka<> 'y'";
|
||
$var="s_".$search_zd;
|
||
if($$var){
|
||
$con.=" and ".$search_zd."='".$$var."'";
|
||
$con_select=" and ".$search_zd."='".$$var."'";
|
||
}else{
|
||
$con_select="";
|
||
}
|
||
if($search_zd=="brand"){
|
||
$con_brand=" and ".$search_zd."='".$$var."'";
|
||
}else{
|
||
$con_brand="";
|
||
}
|
||
//杯型参数
|
||
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;
|
||
}
|
||
$con_u="";
|
||
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);
|
||
$confirm_str=$confirm_str1=$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($is_brand=="y"){
|
||
$m_client_brand=get_db_msg("select is_checked from ".$table_pre."client_brand where cid='".$m_client["id"]."'".$con_brand." order by is_checked limit 0,1");
|
||
$is_checked=$m_client_brand["is_checked"];
|
||
}else{
|
||
$is_checked=$m_client["is_checked"];
|
||
}
|
||
//
|
||
if($m_client["id"]){
|
||
if($m_client["face"]=="4"){
|
||
$con_u.=" (uid='".$m_client["id"]."') or ";
|
||
if($is_checked!="y"){
|
||
$confirm_str.=$arr_username[$i]."(未确认),";
|
||
$confirm_str1.=$arr_username[$i].",";
|
||
}else{
|
||
$confirm_str.=$arr_username[$i]."(已确认),";
|
||
}
|
||
}else{
|
||
$con_u.=" (upath='".$m_client["path"]."-".$m_client["id"]."' or upath like '".$m_client["path"]."-".$m_client["id"]."-%') or ";
|
||
}
|
||
$p_title.=$m_client["title"]."(".$m_client["username"]."),";
|
||
}else{
|
||
$error.=$arr_username[$i].",";
|
||
}
|
||
}
|
||
}
|
||
//
|
||
$con_u_exp="";
|
||
if($s_username_exp){
|
||
$s_username_exp=str_replace(",",",",$s_username_exp);
|
||
//去掉最后一个逗号
|
||
if(substr($s_username_exp,strlen($s_username_exp)-1,1)==",")
|
||
$s_username_exp1=substr($s_username_exp,0,-1);
|
||
else
|
||
$s_username_exp1=$s_username_exp;
|
||
$arr_username_exp=explode(",",$s_username_exp1);
|
||
//去掉重复值
|
||
$arr_username_exp=array_unique($arr_username_exp);
|
||
$title_exp="";
|
||
for($i=0;$i<count($arr_username_exp);$i++){
|
||
//检查是否存在
|
||
$m_client_exp=get_db_msg("select id,title from ".$table_pre."client where username='".$arr_username_exp[$i]."'");
|
||
//
|
||
if($m_client_exp["id"]){
|
||
$con_u_exp.=" (uid<>'".$m_client_exp["id"]."') and ";
|
||
$title_exp.=$m_client_exp["title"].",";
|
||
}
|
||
}
|
||
}
|
||
if($con_u)
|
||
$con.=" and (".substr($con_u,0,-3).") ";
|
||
if($con_u_exp)
|
||
$con.=" and (".substr($con_u_exp,0,-4).") ";
|
||
if($confirm_str)
|
||
$confirm_str=substr($confirm_str,0,-1);
|
||
$json_code.="\"code\":1,";
|
||
$json_data.="\"s_username\":\"".$s_username."\",";
|
||
$json_data.="\"s_username_exp\":\"".$s_username_exp."\",";
|
||
$data_tmp="";
|
||
if($search_zd){
|
||
$json_data.="\"search_zd\":\"".$search_zd."\",";
|
||
$var="s_".$search_zd;
|
||
$json_data.="\"search_zd_value\":\"".$$var."\",";
|
||
//取得选项
|
||
$q="select no,title from ".$table_pre."keyword where cate='".$search_zd."' order by no";
|
||
$r=$db->query($q);
|
||
$op="";
|
||
while($m=$db->fetch_array($r)){
|
||
$op.="{\"no\":\"".$m["no"]."\",\"title\":\"".$m["title"]."\"},";
|
||
}
|
||
$json_data.="\"search_zd_op\":[".deel_end($op)."],";
|
||
}
|
||
if($confirm_str)
|
||
$json_data.="\"confirm_str\":\"".$confirm_str."\",";//订单确认提示
|
||
if($sub=="yes"){
|
||
$sys_client_title=get_set("sys_client_title");
|
||
$dl=get_dl_title($m_client["path"]);
|
||
$title_dl=$dl?$dl."-":"";
|
||
if($title_exp)
|
||
$title_exp=",不含".substr($title_exp,0,-1);
|
||
$title_sub=$title_dl.substr($p_title,0,-1).$title_exp."明细单 ".date("Y年m月d日 H点i分");
|
||
//
|
||
$json_data.="\"print_not_qr\":\"".$print_not_qr."\",";
|
||
$json_data.="\"not_confirm_username\":\"".$confirm_str1."\",";
|
||
//头部信息
|
||
$html_print_top="<div style='font-size:20px;font-weight:bold;line-height:30px;'>".$sys_client_title."</div>";
|
||
$html_print_top.="<div style='font-size:16px;font-weight:bold;line-height:30px;'>".$title_sub."</div>";
|
||
$json_data.="\"print_top\":\"".$html_print_top."\",";
|
||
//-------------------处理尺码表头
|
||
//取得合并尺码
|
||
$arr_size_merged=get_size_merged();
|
||
$num_size_total=count($arr_size_merged);
|
||
//取得尺码合计sql
|
||
$sql_sum_num="";
|
||
for($k=0;$k<$num_size_total;$k++){
|
||
$sql_sum_num.="sum(num_".$arr_size_merged[$k].") 'num_".$arr_size_merged[$k]."',";
|
||
}
|
||
//取得尺码表头内容
|
||
$num_size_group=0;
|
||
$size_tr=array();
|
||
$r1=$db->query("select * from ".$table_pre."keyword where cate='size' order by ord");
|
||
while($m1=$db->fetch_array($r1)){
|
||
$size_tr[$num_size_group]="";
|
||
for($i=1;$i<=$num_size_total;$i++){
|
||
$tmp=get_db_msg("select title from ".$table_pre."size where iid='".$m1["id"]."' and no='".$i."'");
|
||
$t=$tmp["title"]?$tmp["title"]:" ";
|
||
$size_tr[$num_size_group].="{\"title\":\"".$t."\",\"align\":\"center\",\"width\":30},";
|
||
$thead_tmp.="";
|
||
}
|
||
$arr_size_merged[]=$m1["no"];
|
||
$num_size_group++;
|
||
}
|
||
//----输出表头
|
||
$thead="";
|
||
$thead_tmp="";
|
||
for($i=0;$i<count($arr_zd);$i++){
|
||
if($arr_zd[$i]=="kh"){
|
||
$thead_tmp.="{\"title\":\"款号\",\"rowspan\":\"".$num_size_group."\"},";
|
||
}else if($arr_zd[$i]=="xh"){
|
||
$thead_tmp.="{\"title\":\"".d_translate($arr_zd[$i])."\",\"rowspan\":\"".$num_size_group."\",\"width\":50},";
|
||
}else if($arr_zd[$i]=="xs"){
|
||
$thead_tmp.="{\"title\":\"箱数\",\"rowspan\":\"".$num_size_group."\",\"width\":40},";
|
||
}else if($arr_zd[$i]=="num"){
|
||
$thead_tmp.="{\"title\":\"数量\",\"rowspan\":\"".$num_size_group."\",\"width\":40},";
|
||
}else if($arr_zd[$i]=="title" || $arr_zd[$i]=="remark" || $arr_zd[$i]=="color" || $arr_zd[$i]=="color_title" || $arr_zd[$i]=="dpj" || $arr_zd[$i]=="je" || $arr_zd[$i]=="zk" || $arr_zd[$i]=="bx" || $arr_zd[$i]=="jsj" || $arr_zd[$i]=="jsje"){
|
||
$w=($arr_zd[$i]=="jsj" || $arr_zd[$i]=="jsje" || $arr_zd[$i]=="dpj" || $arr_zd[$i]=="je" || $arr_zd[$i]=="zk")?",\"width\":50":"";
|
||
$thead_tmp.="{\"title\":\"".get_main_value($arr_lang,$arr_zd[$i])."\",\"rowspan\":\"".$num_size_group."\"".$w."},";
|
||
}else if($arr_zd[$i]=="size"){
|
||
//尺码明细
|
||
$thead_tmp.=$size_tr[0];
|
||
}else{
|
||
//keyword表
|
||
$thead_tmp.="{\"title\":\"".get_cate_title_no("arr_select",$arr_zd[$i])."\",\"rowspan\":\"".$num_size_group."\"},";
|
||
}
|
||
}
|
||
$thead.="{\"ind\":0,\"content\":[".deel_end($thead_tmp)."]},";
|
||
for($i=1;$i<$num_size_group;$i++){
|
||
$thead.="{\"ind\":".$i.",\"content\":[".deel_end($size_tr[$i])."]},";
|
||
}
|
||
$json_data.="\"thead\":[".deel_end($thead)."],";
|
||
//----------------------------------------------取得订单记录
|
||
$sys_size_num=get_max_size_num();
|
||
$q="select iid,color,bx,uid,upath,dl,qy,sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje',".get_size_sql("sum1")." from ".$table_pre."order where _key='".$s_key."'".$con." group by iid,color,bx order by ".$con_order;
|
||
//echo $q."<br>";
|
||
$r=$db->query($q);
|
||
$total_xs=$total_num=$total_je=$total_jsje=0;
|
||
$total_record=0;
|
||
while($m=$db->fetch_array($r)){
|
||
if($m["num"]>0){
|
||
$m_kh=get_db_msg("select * from ".$table_pre."kh where id='".$m["iid"]."'");
|
||
$arr_kh_size=explode(",",$m_kh["size"]);
|
||
$q4="select * from ".$table_pre."order_pm where uid='".$m["uid"]."' and iid='".$m["iid"]."' and color='".$m["color"]."' and bx='".$m["bx"]."' order by color";
|
||
//echo $q4."<br>";
|
||
$r4=$db->query($q4);
|
||
while($m4=$db->fetch_array($r4)){
|
||
$m_pm=get_db_msg("select * from ".$table_pre."size_pm where id='".$m4["pmid"]."'");
|
||
$arr_pm=explode(":",$m_pm["gz"]);
|
||
$arr_pm1=tz_pm($arr_kh_size,$arr_pm);
|
||
$str_tmp="";
|
||
for($i=0;$i<count($arr_zd);$i++){
|
||
if($arr_zd[$i]=="title" || $arr_zd[$i]=="remark" || $arr_zd[$i]=="zd1" || $arr_zd[$i]=="zd2" || $arr_zd[$i]=="zd3"){
|
||
$str_tmp.="{\"title\":\"".$m_kh[$arr_zd[$i]]."\"},";
|
||
}else if($arr_zd[$i]=="dpj"){
|
||
$str_tmp.="{\"title\":\"".$m_kh["price"]."\"},";
|
||
}else if($arr_zd[$i]=="kh"){
|
||
$str_tmp.="{\"title\":\"".$m_kh["no"]."\"},";
|
||
}else if($arr_zd[$i]=="xh"){
|
||
$xh=get_kh_xh($m_kh,$m["color"]);
|
||
$str_tmp.="{\"title\":\"".$xh."\"},";
|
||
}else if($arr_zd[$i]=="xs"){
|
||
$str_tmp.="{\"title\":\"".$m4["xs"]."\",\"align\":\"right\"},";
|
||
$total_xs+=$m4["xs"];
|
||
}else if($arr_zd[$i]=="num"){
|
||
$str_tmp.="{\"title\":\"".($m_pm["num"]*$m4["xs"])."\",\"align\":\"right\"},";
|
||
$total_num+=$m_pm["num"]*$m4["xs"];
|
||
}else if($arr_zd[$i]=="color_title"){
|
||
$str_tmp.="{\"title\":\"".get_cate_title_no("color",$m["color"])."\"},";
|
||
}else if($arr_zd[$i]=="bx" || $arr_zd[$i]=="color"){
|
||
$str_tmp.="{\"title\":\"".$m[$arr_zd[$i]]."\"},";
|
||
}else if($arr_zd[$i]=="je" || $arr_zd[$i]=="jsje"){
|
||
$str_tmp.="{\"title\":\"".deel_0(deel_num($m[$arr_zd[$i]]))."\",\"align\":\"right\"},";
|
||
}else if($arr_zd[$i]=="jsj"){
|
||
//结算价
|
||
$jsj=0;
|
||
if($m["num"]>0){
|
||
$jsj=deel_num(keep_float($m["jsje"]/$m["num"],1));
|
||
}
|
||
$str_tmp.="{\"title\":\"".$jsj."\"},";
|
||
}else if($arr_zd[$i]=="zk"){
|
||
$zk=deel_num(keep_float($m["jsje"]/$m["je"],2));
|
||
$str_tmp.="{\"".$arr_zd[$i]."\":\"".$zk."\"},";
|
||
}else if($arr_zd[$i]=="size"){
|
||
//尺码明细
|
||
for($k=1;$k<=$num_size_total;$k++){
|
||
$v1="hj_num_".$k;
|
||
$tmp_num=$arr_pm1[$k];
|
||
$str_tmp.="{\"title\":\"".deel_0($tmp_num)."\"},";
|
||
$$v1+=$tmp_num;
|
||
}
|
||
}else{
|
||
//keyword表
|
||
$str_tmp.="{\"title\":\"".get_cate_title_no($arr_zd[$i],$m_kh[$arr_zd[$i]])."\"},";
|
||
}
|
||
}
|
||
|
||
//$total_je+=$m["je"];
|
||
//$total_jsje+=$m["jsje"];
|
||
$data_tmp.="{\"ind\":".$total_record.",\"content\":[".deel_end($str_tmp)."]},";
|
||
$total_record++;
|
||
}
|
||
}
|
||
}
|
||
//-----------合计行
|
||
//计算尺码所在index
|
||
$size_index=0;
|
||
for($i=0;$i<count($arr_zd);$i++){
|
||
if($arr_zd[$i]=="size")
|
||
$size_index=$i;
|
||
}
|
||
if($size_index==0){
|
||
//计算num所在index
|
||
$num_index=0;
|
||
for($i=0;$i<count($arr_zd);$i++){
|
||
if($arr_zd[$i]=="num")
|
||
$num_index=$i;
|
||
}
|
||
if($num_index>0){
|
||
//没有尺码,但是有小计
|
||
$colspan=$num_index;
|
||
//
|
||
$str_tmp="{\"title\":\"合计\",\"colspan\":".$colspan.",\"align\":\"right\"},";
|
||
$str_tmp.="{\"title\":\"".$total_num."\",\"align\":\"right\"},";
|
||
for($i=$num_index+1;$i<count($arr_zd);$i++){
|
||
if($arr_zd[$i]=="jsje" || $arr_zd[$i]=="je" || $arr_zd[$i]=="num" || $arr_zd[$i]=="xs"){
|
||
$var="total_".$arr_zd[$i];
|
||
$str_tmp.="{\"title\":\"".$$var."\",\"align\":\"right\"},";
|
||
}else{
|
||
$str_tmp.="{\"title\":\" \"},";
|
||
}
|
||
}
|
||
$data_tmp.="{\"ind\":".$total_record.",\"content\":[".deel_end($str_tmp)."]},";
|
||
}
|
||
}else{
|
||
$colspan=$size_index;
|
||
//
|
||
$str_tmp="{\"title\":\"合计\",\"colspan\":".$colspan.",\"align\":\"right\"},";
|
||
for($k1=1;$k1<=$num_size_total;$k1++){
|
||
$v1="hj_num_".$k1;
|
||
$str_tmp.="{\"title\":\"".deel_0($$v1)."\"},";
|
||
}
|
||
for($i=$size_index+1;$i<count($arr_zd);$i++){
|
||
if($arr_zd[$i]=="jsje" || $arr_zd[$i]=="je" || $arr_zd[$i]=="num" || $arr_zd[$i]=="xs"){
|
||
$var="total_".$arr_zd[$i];
|
||
$str_tmp.="{\"title\":\"".$$var."\",\"align\":\"right\"},";
|
||
}else{
|
||
$str_tmp.="{\"title\":\" \"},";
|
||
}
|
||
}
|
||
$data_tmp.="{\"ind\":".$total_record.",\"content\":[".deel_end($str_tmp)."]},";
|
||
}
|
||
$json_data.="\"tbody\":[".deel_end($data_tmp)."],";
|
||
$json_data.="\"tbody_num\":".$total_record.",";
|
||
}
|
||
|
||
?>
|