7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
412 lines
15 KiB
PHP
412 lines
15 KiB
PHP
<?php
|
|
//订单管理
|
|
if(THIS_IN!="edt_c")
|
|
exit("错误的访问!");
|
|
require THIS_FILE_ROOT."/include/excel_class.php";
|
|
require THIS_FILE_ROOT."/include/excel_fun.php";
|
|
$uid=check_cookie();
|
|
$db=_mysql_connect();
|
|
$msg_login_user=get_db_msg("select * from ".$table_pre."client where id='".$uid."'");
|
|
$_title_=$_title_?$_title_:"订单录入";
|
|
|
|
$_nav_="<a href=\"./\">首页</a> > <a href=\"".$_SERVER[PHP_SELF]."?_m=".$_m."&_cid=".$_cid."\">".$_title_."</a>";
|
|
$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;
|
|
}
|
|
switch($_a){
|
|
case "save_add_dd":
|
|
if(!$dp_id){
|
|
alert_and_back("请选择店铺!");
|
|
}
|
|
if(!$khid){
|
|
alert_and_back("请输入款号!");
|
|
}
|
|
$dp_info=get_db_msg("select * from web_client where id='".$dp_id."'");
|
|
if($dp_info["is_checked"]=="y"){
|
|
alert_and_back("操作失败,原因是本用户订单已经确认!");
|
|
}
|
|
//判断是否存在规格
|
|
$is_ggk=is_ggk($khid);
|
|
//保存订单
|
|
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$khid."'");
|
|
if($msg["size_group"]==$bx_sizegroup_id){
|
|
//取得杯型
|
|
$arrBx=array();
|
|
$str_bx="";
|
|
$r1=$db->query("select * from ".$table_pre."size_bx where no='".$msg["no"]."' order by bx");
|
|
$i1=0;
|
|
while($m1=$db->fetch_array($r1)){
|
|
$arrBx[$i1][]=$m1["bx"];
|
|
$arrBx[$i1][]=$m1["size"];
|
|
$str_bx.=$m1["bx"].",";
|
|
$i1++;
|
|
}
|
|
//取得尺码
|
|
$str_size="";
|
|
$r1=$db->query("select * from ".$table_pre."size where iid='".$bx_sizegroup_id."' order by no");
|
|
while($m1=$db->fetch_array($r1)){
|
|
$str_size.=$m1["no"].",";
|
|
}
|
|
$str_size=substr($str_size,0,-1);
|
|
$arr_size=explode(",",$str_size);
|
|
}else{
|
|
if($is_ggk=="y"){
|
|
$r1=$db->query("select * from ".$table_pre."kh_gg where iid='".$msg["id"]."' order by color,ord");
|
|
$i1=0;
|
|
while($m1=$db->fetch_array($r1)){
|
|
$arrBx[$i1][]=$m1["gg"];
|
|
$str_bx.=$m1["gg"].",";
|
|
$i1++;
|
|
}
|
|
$arr_size=explode(",",$msg["size"]);
|
|
}else{
|
|
$arrBx[0][0]="";
|
|
$arrBx[0][1]=$msg["size"];
|
|
$arr_size=explode(",",$arrBx[0][1]);
|
|
$str_bx="";
|
|
}
|
|
}
|
|
if($str_bx)
|
|
$str_bx=substr($str_bx,0,-1);
|
|
//
|
|
$arr_color=explode(",",$msg["color"]);
|
|
$arr_color_ka=explode(",",$msg["color_ka"]);
|
|
$tmp_total_num=0;
|
|
$tmp_old=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where uid='".$uid."' and iid='".$id."'");
|
|
//取得总量
|
|
for($i=0;$i<count($arr_color);$i++){
|
|
for($j=0;$j<count($arrBx);$j++){
|
|
for($k=0;$k<count($arr_size);$k++){
|
|
$v="num_".$arr_color[$i]."_".$arrBx[$j][0]."_".$arr_size[$k];
|
|
$tmp_total_num+=$$v;
|
|
//echo $v."|".$$v."<br>";
|
|
}
|
|
}
|
|
}
|
|
//取得选项
|
|
$arr_select_no=array();
|
|
$q1="select no from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'jgd' and no<>'sx' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord";
|
|
$r1=$db->query($q1);
|
|
while($m1=$db->fetch_array($r1)){
|
|
$arr_select_no[]=$m1["no"];
|
|
}
|
|
for($i=0;$i<count($arr_color);$i++){
|
|
$check1=get_db_msg("select * from ".$table_pre."kh_dp where kh='".$msg["no"]."' and color='".$arr_color[$i]."' and gz='1' limit 0,1");
|
|
if(!in_array($arr_color[$i],$arr_color_ka) && !$check1["id"]){
|
|
for($j=0;$j<count($arrBx);$j++){
|
|
$sql_size1=$sql_size2=$sql_size3="";
|
|
$c=0;
|
|
for($k=0;$k<count($arr_size);$k++){
|
|
$v="num_".$arr_color[$i]."_".$arrBx[$j][0]."_".$arr_size[$k];
|
|
$c+=$$v;
|
|
$sql_size1.="num_".$arr_size[$k]."='".$$v."',";
|
|
$sql_size2.=",'".$$v."'";
|
|
$sql_size3.=",num_".$arr_size[$k];
|
|
}
|
|
$check=get_db_msg("select id from ".$table_pre."order where _key='".$_key."' and uid='".$dp_id."' and iid='".$khid."' and color='".$arr_color[$i]."' and bx='".$arrBx[$j][0]."'");
|
|
if($check["id"]){
|
|
if($c>0){
|
|
$q="update ".$table_pre."order set size_group_id='".$msg["size_group"]."',".$sql_size1."add_date='".time()."' where id='".$check["id"]."'";
|
|
$db->query($q);
|
|
cache_order($dp_id,$khid,$arr_color[$i],$arrBx[$j][0]);
|
|
}else{
|
|
$q="delete from ".$table_pre."order where id='".$check["id"]."'";
|
|
$db->query($q);
|
|
}
|
|
}else{
|
|
if($c>0){
|
|
$sql1=$sql2="";
|
|
for($i1=0;$i1<count($arr_select_no);$i1++){
|
|
$sql1.=$arr_select_no[$i1].",";
|
|
$sql2.="'".$msg[$arr_select_no[$i1]]."',";
|
|
}
|
|
$gg=$arrBx[$j][0];
|
|
$gg_color=$arr_color[$i];
|
|
$q="insert into ".$table_pre."order (uid,upath,iid,no,".$sql1."jgd,color,bx,is_sp,size_group_id".$sql_size3.",_key,price,sx,add_date) values ('".$dp_id."','".$dp_info["path"]."-".$dp_info["id"]."','".$khid."','".$msg["no"]."',".$sql2."'".get_jgd($msg["price"])."','".$arr_color[$i]."','".$arrBx[$j][0]."','".$msg["is_sp"]."','".$msg["size_group"]."'".$sql_size2.",'".$_key."','".$msg["price"]."','".get_sx($arr_color[$i])."','".time()."')";
|
|
$db->query($q);
|
|
cache_order($dp_id,$khid,$arr_color[$i],$arrBx[$j][0]);
|
|
}
|
|
}
|
|
}
|
|
count_ph($dp_id,$khid,$arr_color[$i]);
|
|
}
|
|
}
|
|
//计算数量变化
|
|
//echo $q;
|
|
$log_hd_old_num=$tmp_old["num"];
|
|
$log_hd_num=$tmp_total_num-$tmp_old["num"];
|
|
//
|
|
//update_log_hd();
|
|
set_order_total($dp_id);
|
|
url_redirect("index.php?_m=system/order&_a=add_dd&dp_id=".$dp_id);
|
|
break;
|
|
case "del":
|
|
//删除订单
|
|
$msg_client=get_db_msg("select * from ".$table_pre."client where id='".$dpid."'");
|
|
if($msg_client["is_checked"]=="y"){
|
|
alert_and_back("操作失败,原因是本用户订单已经确认!");
|
|
}
|
|
$q="delete from ".$table_pre."order where iid='".$khid."' and uid='".$dpid."'";
|
|
$db->query($q);
|
|
//计算排行
|
|
$msg_kh=get_db_msg("select id,color from ".$table_pre."kh where id='".$khid."'");
|
|
$arr_color=explode(",",$msg_kh["color"]);
|
|
for($i=0;$i<count($arr_color);$i++){
|
|
count_ph($dpid,$khid,$arr_color[$i]);
|
|
}
|
|
set_order_total($dpid);
|
|
$url=$_SERVER[PHP_SELF]."?_m=system/order&_a=add_dd&dp_id=".$dpid."&khid=".$khid;
|
|
url_redirect($url);
|
|
break;
|
|
//-------------主界面
|
|
default :
|
|
$js_start="y";
|
|
$add_date=date("Y-m-d H:i:s");
|
|
$tmp=get_db_msg("select * from ".$table_pre."client where id='".$uid."'");
|
|
//判断是不是代理
|
|
if($tmp["face"]!="4"){
|
|
$dp_info=get_db_msg("select * from web_client where id='".$dp_id."'");
|
|
$dp_name=$dp_info["title"];
|
|
$str_path=$tmp["path"]."-".$tmp["id"];
|
|
//取得店铺自动完成
|
|
$str2="var dp_id=\"".$dp_id."\";";
|
|
$str2.="var dps = [\n";
|
|
if($tmp["face"]=="2"){
|
|
$arr_upath=explode(",",$tmp["charge_path"]);
|
|
$i2=0;
|
|
for($i=0;$i<count($arr_upath);$i++){
|
|
$m2=get_db_msg("select face,id,title,username,available,is_checked from ".$table_pre."client where id='".get_parent_id($arr_upath[$i])."'");
|
|
if($m2["face"]=="4" && $m2["available"]=="y" && $m2["is_checked"]!="y"){
|
|
$str2.="{id:\"".$m2["id"]."\",title:\"".$m2["title"]."\",username:\"".$m2["username"]."\"},\n";
|
|
$i2++;
|
|
}
|
|
}
|
|
}else{
|
|
$q2="select id,title,username from ".$table_pre."client where (path='".$str_path."' or path like '".$str_path."-%') and face='4' and available='y' and is_checked<>'y' order by id";
|
|
$r2=$db->query($q2);
|
|
$i2=0;
|
|
while($m2=$db->fetch_array($r2)){
|
|
$str2.="{id:\"".$m2["id"]."\",title:\"".$m2["title"]."\",username:\"".$m2["username"]."\"},\n";
|
|
$i2++;
|
|
}
|
|
}
|
|
if($i2>0)
|
|
$str2=substr($str2,0,-2);
|
|
$str2.="];\n";
|
|
$js_function=$str2."\n";
|
|
$js_function.="$(function() {
|
|
$('#dp').autocomplete(dps, {
|
|
max: 100, //列表里的条目数
|
|
minChars: 0, //自动完成激活之前填入的最小字符
|
|
width: 300, //提示的宽度,溢出隐藏
|
|
scrollHeight: 300, //提示的高度,溢出显示滚动条
|
|
matchContains: true, //包含匹配,就是data参数里的数据,是否只要包含文本框里的数据就显示
|
|
autoFill: false, //自动填充
|
|
formatItem: function(row, i, max) {
|
|
return row.title+'('+row.username+')';
|
|
},
|
|
formatMatch: function(row, i, max) {
|
|
return row.title+row.username;
|
|
},
|
|
formatResult: function(row) {
|
|
return row.id;
|
|
}
|
|
}).result(function(event, row, formatted) {
|
|
document.form1.dp.value=row.title;
|
|
document.form1.dp_id.value=row.id;
|
|
dp_id=row.id;
|
|
ajax_get_color3(row.username);
|
|
ajax_get_color4(row.username);
|
|
if(document.form1.khid.value !=\"\"){
|
|
ajax_get_color2(row.id,document.form1.khid.value);
|
|
}
|
|
});
|
|
});\n";
|
|
$js_function.="
|
|
function ajax_get_color2(id,khid){
|
|
var dp_id=parseInt(document.getElementById('dp_id').value);
|
|
if(id>0 && dp_id>0){
|
|
//ajax
|
|
var obj=document.getElementById(\"tr_td\");
|
|
var xmlhttp=ajaxinit();
|
|
var url=\"?_m=manage/ajax_kh_color2&id=\"+khid+\"&dp_id=\"+id;
|
|
xmlhttp.open(\"POST\",url,true);
|
|
xmlhttp.setRequestHeader(\"Cache-Control\",\"no-cache\");
|
|
xmlhttp.onreadystatechange=function(){
|
|
if(xmlhttp.readyState==4 && xmlhttp.status==200){
|
|
//alert(xmlhttp.responseText);
|
|
obj.innerHTML=xmlhttp.responseText;
|
|
}
|
|
}
|
|
xmlhttp.send(null);
|
|
}else{
|
|
if(!dp_id)
|
|
alert('请输入店铺!');
|
|
return;
|
|
}
|
|
}
|
|
function ajax_get_color3(username){
|
|
//ajax
|
|
var obj=document.getElementById(\"tr_td2\");
|
|
var xmlhttp=ajaxinit();
|
|
var url=\"?_m=manage/ajax_kh_color3&username=\"+username;
|
|
xmlhttp.open(\"POST\",url,true);
|
|
xmlhttp.setRequestHeader(\"Cache-Control\",\"no-cache\");
|
|
xmlhttp.onreadystatechange=function(){
|
|
if(xmlhttp.readyState==4 && xmlhttp.status==200){
|
|
//alert(xmlhttp.responseText);
|
|
obj.innerHTML=xmlhttp.responseText;
|
|
}
|
|
}
|
|
xmlhttp.send(null);
|
|
}
|
|
function ajax_get_color4(username){
|
|
//ajax
|
|
var obj=document.getElementById(\"tr_td3\");
|
|
var xmlhttp=ajaxinit();
|
|
var url=\"?_m=manage/ajax_kh_color4&username=\"+username;
|
|
xmlhttp.open(\"POST\",url,true);
|
|
xmlhttp.setRequestHeader(\"Cache-Control\",\"no-cache\");
|
|
xmlhttp.onreadystatechange=function(){
|
|
if(xmlhttp.readyState==4 && xmlhttp.status==200){
|
|
//alert(xmlhttp.responseText);
|
|
obj.innerHTML=xmlhttp.responseText;
|
|
}
|
|
}
|
|
xmlhttp.send(null);
|
|
}";
|
|
$dp_select="<input type=text name=\"dp\" id=\"dp\" onkeydown=\"jump('kh')\" style=\"width:300px\" onfocus=\"this.select()\" value=\"".$dp_name."\">";
|
|
}else{
|
|
$dp_info=get_db_msg("select * from web_client where id='".$uid."'");
|
|
$dp_name=$dp_info["title"];
|
|
$str_face="";
|
|
$str="var dp_id=\"".$uid."\";";
|
|
$dp_id=$uid;
|
|
}
|
|
//取得款号自动完成
|
|
$str.="var khs = [\n";
|
|
$q="select id,no,title,xh from ".$table_pre."kh ".$con." order by no";
|
|
$r=$db->query($q);
|
|
$i=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$str.="{id:\"".$m["id"]."\",no:\"".$m["no"]."\",xh:\"".$m["xh"]."\",title:\"".$m["title"]."\"},\n";
|
|
$i++;
|
|
}
|
|
if($i>0)
|
|
$str=substr($str,0,-2);
|
|
$str.="];\n";
|
|
$js_function.=$str."\n";
|
|
$js_function.="$(function() {
|
|
$('#kh').autocomplete(khs, {
|
|
max: 100, //列表里的条目数
|
|
minChars: 0, //自动完成激活之前填入的最小字符
|
|
width: 200, //提示的宽度,溢出隐藏
|
|
scrollHeight: 300, //提示的高度,溢出显示滚动条
|
|
matchContains: true, //包含匹配,就是data参数里的数据,是否只要包含文本框里的数据就显示
|
|
autoFill: false, //自动填充
|
|
formatItem: function(row, i, max) {
|
|
return row.no+','+row.title;
|
|
},
|
|
formatMatch: function(row, i, max) {
|
|
return row.no;
|
|
},
|
|
formatResult: function(row) {
|
|
return row.id;
|
|
}
|
|
}).result(function(event, row, formatted) {
|
|
document.form1.khid.value=row.id;
|
|
document.form1.kh.value=row.no;
|
|
document.form1.xh.value=row.xh;
|
|
ajax_get_color(row.id);
|
|
});
|
|
});\n
|
|
$(function() {
|
|
$('#xh').autocomplete(khs, {
|
|
max: 100, //列表里的条目数
|
|
minChars: 0, //自动完成激活之前填入的最小字符
|
|
width: 200, //提示的宽度,溢出隐藏
|
|
scrollHeight: 300, //提示的高度,溢出显示滚动条
|
|
matchContains: true, //包含匹配,就是data参数里的数据,是否只要包含文本框里的数据就显示
|
|
autoFill: false, //自动填充
|
|
formatItem: function(row, i, max) {
|
|
return row.xh+','+row.title;
|
|
},
|
|
formatMatch: function(row, i, max) {
|
|
return row.xh;
|
|
},
|
|
formatResult: function(row) {
|
|
return row.id;
|
|
}
|
|
}).result(function(event, row, formatted) {
|
|
document.form1.khid.value=row.id;
|
|
document.form1.xh.value=row.xh;
|
|
document.form1.kh.value=row.no;
|
|
ajax_get_color(row.id);
|
|
});
|
|
});\n";
|
|
$js_function.="
|
|
function ajax_get_color(id){
|
|
var dp_id=parseInt(document.getElementById('dp_id').value);
|
|
if(id>0 && dp_id>0){
|
|
//ajax
|
|
var obj=document.getElementById(\"tr_td\");
|
|
var xmlhttp=ajaxinit();
|
|
var url=\"?_m=manage/ajax_kh_color2&id=\"+id+\"&dp_id=\"+dp_id;
|
|
xmlhttp.open(\"POST\",url,true);
|
|
xmlhttp.setRequestHeader(\"Cache-Control\",\"no-cache\");
|
|
xmlhttp.onreadystatechange=function(){
|
|
if(xmlhttp.readyState==4 && xmlhttp.status==200){
|
|
//alert(xmlhttp.responseText);
|
|
obj.innerHTML=xmlhttp.responseText;
|
|
}
|
|
}
|
|
xmlhttp.send(null);
|
|
}else{
|
|
if(!dp_id)
|
|
alert('请输入店铺!');
|
|
return;
|
|
}
|
|
}";
|
|
if($tmp["face"]==4){
|
|
$content[]=array("店铺代码",$dp_info["username"]);
|
|
$content[]=array("店铺名称",$dp_info["title"]);
|
|
$content[]=array("已订件数",$dp_info["order_num"]."件");
|
|
$content[]=array("已订金额",deel_je_show($dp_info["order_money_zk"]));
|
|
}else{
|
|
$content[]=array("店铺代码或名称",$dp_select);
|
|
$content[]=array("已订件数","<div id=\"tr_td2\">".$dp_info[order_num]."</div>");
|
|
$content[]=array("已订金额","<div id=\"tr_td3\">".deel_je_show($dp_info["order_money_zk"])."</div>");
|
|
}
|
|
$content[]=array("圆牌号/款号","<input type=text name=\"xh\" id=\"xh\" onkeydown=\"jump('tx_0')\" style=\"width:50px\" onfocus=\"this.select()\" value=\"\"> / <input type=text name=\"kh\" id=\"kh\" onkeydown=\"jump('tx_0')\" style=\"width:180px\" onfocus=\"this.select()\" value=\"\"><input type=\"hidden\" value=\"\" name=\"khid\" id=\"khid\"><input type=\"hidden\" value=\"".$dp_id."\" name=\"dp_id\" id=\"dp_id\">");
|
|
$content[]=array("数量","<div id=\"tr_td\">请选择款号!</div>");
|
|
//js_code
|
|
$js_code="function ok(){
|
|
obj=document.form1;
|
|
return true;
|
|
}";
|
|
$js_code.="
|
|
var this_input_value=0;
|
|
function save_this_value(v){
|
|
this_input_value=v;
|
|
}
|
|
function total_hj(a,b,c){
|
|
var obj=document.getElementById('label_'+a).innerHTML;
|
|
var obj2=document.getElementById(b).value;
|
|
var obj3=document.getElementById('label_xj_'+c).innerHTML;
|
|
var obj4=document.getElementById('label_zj').innerHTML;
|
|
document.getElementById('label_'+a).innerHTML=parseFloat(obj)+parseFloat(obj2)-this_input_value;
|
|
document.getElementById('label_xj_'+c).innerHTML=parseFloat(obj2)+parseFloat(obj3)-this_input_value;
|
|
document.getElementById('label_zj').innerHTML=parseFloat(obj4)+parseFloat(obj2)-this_input_value;
|
|
}";
|
|
//
|
|
$form_property=" onsubmit=\"return ok()\"";
|
|
$form_hidden=array("_a"=>"save_add_dd","http_pre"=>$_SERVER['HTTP_REFERER']);
|
|
$_width_="100";
|
|
include template("manage_add");
|
|
break;
|
|
}
|
|
?>
|