7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
312 lines
12 KiB
PHP
312 lines
12 KiB
PHP
<?php
|
|
|
|
header("Content-type: text/html; charset=utf-8");
|
|
$json_data="{";
|
|
|
|
|
|
$m_kh=get_db_msg("select no,pm_dj,size,size_group from ".$table_pre."kh where id='".$iid."'");
|
|
$m_client=get_db_msg("select path,username from ".$table_pre."client where id='".$dpid."'");
|
|
$json_data.="\"uid\":\"".$dpid."\",";
|
|
$json_data.="\"iid\":\"".$iid."\",";
|
|
$json_data.="\"_m\":\"".$_m."\",";
|
|
switch($_a){
|
|
case "add":
|
|
if($id){
|
|
$msg=get_db_msg("select * from ".$table_pre."size_pm where id='".$id."'");
|
|
$title=$msg["title"];
|
|
$gz=$msg["gz"];
|
|
$arr_gz=explode(":",$gz);
|
|
$hj=$msg["num"];
|
|
}else{
|
|
$id="";
|
|
$gz="";
|
|
$title="";
|
|
$arr_gz=array();
|
|
$hj=0;
|
|
}
|
|
//取得尺码
|
|
$str_size="";
|
|
$arr_size=explode(",",$m_kh["size"]);
|
|
//计算尺码框宽度
|
|
$size_w=floor(200/count($arr_size));
|
|
$size_w=$size_w>30?30:$size_w;
|
|
$arr_size_title=array();
|
|
$tr_size_title=$tr_size_input="";
|
|
$str_s="";
|
|
for($j=0;$j<count($arr_size);$j++){
|
|
$m1=get_db_msg("select title from ".$table_pre."size where iid='".$m_kh["size_group"]."' and no='".$arr_size[$j]."'");
|
|
$arr_size_title[$j]=$m1["title"];
|
|
$tr_size_title.="<td width='".$size_w."'>".$m1["title"]."</td>";
|
|
$tr_size_input.="<td><input type='number' id='gz_".$arr_size[$j]."' name='gz_".$arr_size[$j]."' value='".$arr_gz[$j]."' style='width:".$size_w."px;font-size:9pt;' onchange=\"this.value=Math.abs(this.value.replace(/\D/g,'0'));count_hj();\"></td>";
|
|
$str_size.=$m1["title"].":";
|
|
$str_s.="{\"title\":\"".$m1["title"]."\",\"id\":\"gz_".$arr_size[$j]."\",\"value\":\"".$arr_gz[$j]."\"},";
|
|
}
|
|
if($str_s){
|
|
$str_s=deel_end($str_s);
|
|
}
|
|
if($str_size)
|
|
$str_size=substr($str_size,0,-1);
|
|
//取得装箱数
|
|
$arr_zxs=array();
|
|
$q1="select num from ".$table_pre."gz where cate='zxs' and (dj='".$m_client["username"]."' or dj='') and kh='".$m_kh["no"]."' order by num";
|
|
$r1=$db->query($q1);
|
|
while($m1=$db->fetch_array($r1)){
|
|
$arr_zxs[]=$m1["num"];
|
|
}
|
|
if($arr_zxs){
|
|
$str_zxs=arr_to_str($arr_zxs);
|
|
$zxs=$arr_zxs[0];
|
|
}else{
|
|
$str_zxs="";
|
|
$zxs=0;
|
|
}
|
|
$content="<script>
|
|
function count_hj(){
|
|
//计算合计
|
|
var str_size=\"".$m_kh["size"]."\";
|
|
var arr_size=str_size.split(',');
|
|
var hj=0;
|
|
for(var i=0;i<arr_size.length;i++){
|
|
var obj1=document.getElementById('gz_'+arr_size[i]);
|
|
if(obj1){
|
|
if(obj1.value){
|
|
hj+=parseInt(obj1.value);
|
|
}
|
|
}
|
|
}
|
|
document.getElementById('hj').innerHTML=hj;
|
|
//自动填充最后一格
|
|
var zxs=".$zxs.";
|
|
if(zxs>0){
|
|
var last_null_id='';
|
|
var null_num=0;
|
|
var hj1=0;
|
|
for(var i=0;i<arr_size.length;i++){
|
|
var obj1=document.getElementById('gz_'+arr_size[i]);
|
|
if(obj1){
|
|
if(obj1.value){
|
|
hj1+=parseInt(obj1.value);
|
|
}else{
|
|
last_id='gz_'+arr_size[i];
|
|
null_num++;
|
|
}
|
|
}
|
|
}
|
|
if(null_num==1){
|
|
if(zxs-hj1>0){
|
|
document.getElementById(last_id).value=zxs-hj1;
|
|
document.getElementById('hj').innerHTML=zxs;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function add_pm(){
|
|
var obj=document.getElementById('form_pm');
|
|
if(obj.title.value==''){
|
|
alert('请输入名称!');
|
|
return false;
|
|
}
|
|
obj.sub1.value='保存中...';
|
|
obj.sub1.disabled=true;
|
|
return true;
|
|
}
|
|
</script>";
|
|
$content.="<form name='form_pm' id='form_pm' action='".$_SERVER["PHP_SELF"]."' method='post' onsubmit='return add_pm();' target='frame_pm'><input type='hidden' name='_m' value='".$_m."'><input type='hidden' name='dpid' value='".$dpid."'><input type='hidden' name='iid' value='".$iid."'><input type='hidden' name='obj' value='".$obj."'><input type='hidden' name='id' value='".$id."'><input type='hidden' name='_a' value='save_add'><table border=\"0\" cellspacing=\"1\" cellpadding=\"1\" align=\"left\" bgcolor='#cccccc'>";
|
|
$content.="<tr bgcolor='#f0f0f0'><td width='50'>名称</td>".$tr_size_title."<td align='center' width='25'>".$str_zxs."</td></tr>";
|
|
$content.="<tr bgcolor='#ffffff'><td><input type='text' id='title' name='title' value='".$title."' style='width:50px;'></td>".$tr_size_input."<td align='center'><div id='hj'>".$hj."</div></td></tr>";
|
|
$content.="<tr bgcolor='#ffffff'><td colspan='".(2+count($arr_size))."'><input type='submit' name='sub1' id='sub1' value='保存'> <input type='button' name='back' id='back' value='返回' onclick='history.back();'></td></tr>";
|
|
$content.="</table></form>";
|
|
|
|
$json_data.="\"id\":\"".$id."\",";
|
|
$json_data.="\"obj\":\"".$obj."\",";
|
|
$json_data.="\"gz\":\"".$gz."\",";
|
|
$json_data.="\"title\":\"".$title."\",";
|
|
$json_data.="\"zxs\":\"".$str_zxs."\",";
|
|
$json_data.="\"size\":[".$str_s."],";
|
|
$json_data.="\"hj\":\"".$hj."\",";
|
|
break;
|
|
case "save_add":
|
|
$title=trim($title);
|
|
if(strstr($title,"|")){
|
|
//alert_and_back("非法字串“|”,请检查!");
|
|
$msg="非法字串“|”,请检查!";
|
|
}
|
|
if(!$title){
|
|
if(!$msg){
|
|
$msg="配码名称不能为空";
|
|
}
|
|
}
|
|
//
|
|
$num=0;
|
|
//检查是否符合尺码数量
|
|
$gz="";
|
|
$arr_size=explode(",",$m_kh["size"]);
|
|
for($i=0;$i<count($arr_size);$i++){
|
|
$var="gz_".$arr_size[$i];
|
|
$arr_gz[$i]=$$var;
|
|
$num+=$$var;
|
|
$gz.=$$var.":";
|
|
}
|
|
if($gz)
|
|
$gz=substr($gz,0,-1);
|
|
if(count($arr_size)!=count($arr_gz)){
|
|
//alert_and_back("对不起,配码数与尺码数不符,请检查!");
|
|
if(!$msg){
|
|
$msg="对不起,配码数与尺码数不符,请检查!";
|
|
}
|
|
}
|
|
//检查是否符合装箱数
|
|
$arr_zxs=array();
|
|
$q1="select num from ".$table_pre."gz where cate='zxs' and (dj='".$m_client["username"]."' or dj='') and kh='".$m_kh["no"]."' order by num";
|
|
$r1=$db->query($q1);
|
|
while($m1=$db->fetch_array($r1)){
|
|
$arr_zxs[]=$m1["num"];
|
|
}
|
|
if($arr_zxs){
|
|
if(!in_array($num,$arr_zxs)){
|
|
//alert_and_back("对不起,配码不符合装箱数,请检查!");
|
|
if(!$msg){
|
|
$msg="对不起,配码不符合装箱数,请检查!";
|
|
}
|
|
}
|
|
}
|
|
//
|
|
//检查是否存在
|
|
$check=get_db_msg("select id from ".$table_pre."size_pm where uid='".$dpid."' and pm_dj='".$m_kh["pm_dj"]."' and gz='".$gz."' and id<>'".$id."'");
|
|
if($check["id"]>0){
|
|
$rurl="?_m=".$_m."&dpid=".$dpid."&iid=".$iid."&obj=".$obj;
|
|
//取得配码行数
|
|
$tmp1=get_db_msg("select count(*) 'num' from ".$table_pre."size_pm where uid='".$dpid."' and pm_dj='".$m_kh["pm_dj"]."'");
|
|
$pm_rows=deel_num($tmp1["num"]);
|
|
//echo "<html><head><meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\"></head><body><script> alert('保存失败!(该配码已经存在)');window.parent.set_pm_div_h(".$pm_rows.",'".$obj."');window.parent.location.href='".$rurl."'; </script></body></html>";
|
|
//exit();
|
|
if(!$msg){
|
|
$msg="保存失败!(该配码已经存在)";
|
|
}
|
|
}
|
|
$qy_uid=get_qy_id($m_client["path"]);
|
|
if($id>0){
|
|
//修改
|
|
$msg_old=get_db_msg("select * from ".$table_pre."size_pm where id='".$id."'");
|
|
if($msg_old["gz"]!=$gz){
|
|
//如果已经有订单用了,不允许修改
|
|
$check1=get_db_msg("select count(*) 'num' from ".$table_pre."order_pm where pmid='".$id."'");
|
|
if($check1["num"]>0){
|
|
//alert_and_back("对不起,该配码已经使用,不允许修改!");
|
|
if(!$msg){
|
|
$msg="对不起,该配码已经使用,不允许修改!";
|
|
}
|
|
}
|
|
}
|
|
if($msg){
|
|
$json_data.="\"code\":0,\"msg\":\"".$msg."\",";
|
|
}else{
|
|
$q1="update ".$table_pre."size_pm set title='".$title."',gz='".$gz."',num='".$num."' where id='".$id."'";
|
|
$db->query($q1);
|
|
$json_data.="\"code\":101,";
|
|
}
|
|
}else{
|
|
if($msg){
|
|
$json_data.="\"code\":0,\"msg\":\"".$msg."\",";
|
|
}else{
|
|
//新增
|
|
$q1="insert into ".$table_pre."size_pm (qyid,uid,size_group_id,pm_dj,title,gz,num) values ('".$qy_uid."','".$dpid."','".$m_kh["size_group"]."','".$m_kh["pm_dj"]."','".$title."','".$gz."','".$num."')";
|
|
$db->query($q1);
|
|
$json_data.="\"code\":101,";
|
|
}
|
|
}
|
|
$rurl="?_m=".$_m."&dpid=".$dpid."&iid=".$iid."&obj=".$obj;
|
|
//取得配码行数
|
|
$tmp1=get_db_msg("select count(*) 'num' from ".$table_pre."size_pm where uid='".$dpid."' and pm_dj='".$m_kh["pm_dj"]."'");
|
|
$pm_rows=deel_num($tmp1["num"]);
|
|
$json_data.="\"pm_rows\":\"".$pm_rows."\",";
|
|
//echo "<html><head><meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\"></head><body><script> alert('保存成功');window.parent.set_pm_div_h(".$pm_rows.",'".$obj."');window.parent.location.href='".$rurl."'; </script></body></html>";
|
|
//exit();
|
|
break;
|
|
case "del":
|
|
$check1=get_db_msg("select count(*) 'num' from ".$table_pre."order_pm where pmid='".$id."'");
|
|
if($check1["num"]>0){
|
|
//alert_and_back("对不起,该配码已经使用,不允许删除!");
|
|
$msg="对不起,该配码已经使用,不允许删除!";
|
|
}
|
|
$check2=get_db_msg("select uid from ".$table_pre."size_pm where id='".$id."'");
|
|
if($check2["uid"]!=$dpid){
|
|
//alert_and_back("对不起,该配码已经使用,不允许删除!");
|
|
$msg="对不起,只能修改自己的配码!";
|
|
}
|
|
if($msg){
|
|
$json_data.="\"code\":0,\"msg\":\"".$msg."\",";
|
|
}else{
|
|
$q="delete from ".$table_pre."size_pm where id='".$id."'";
|
|
$db->query($q);
|
|
$json_data.="\"code\":101,";
|
|
}
|
|
$rurl="?_m=".$_m."&dpid=".$dpid."&iid=".$iid."&obj=".$obj;
|
|
//取得配码行数
|
|
$tmp1=get_db_msg("select count(*) 'num' from ".$table_pre."size_pm where uid='".$dpid."' and pm_dj='".$m_kh["pm_dj"]."'");
|
|
$pm_rows=deel_num($tmp1["num"]);
|
|
$json_data.="\"pm_rows\":\"".$pm_rows."\",";
|
|
//echo "<html><head><meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\"></head><body><script> alert('删除成功');window.parent.set_pm_div_h(".$pm_rows.",'".$obj."');window.parent.location.href='".$rurl."'; </script></body></html>";
|
|
//exit();
|
|
break;
|
|
default:
|
|
$content="<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" width=\"100%\">";
|
|
$content.="<tr><td align=\"left\" bgcolor=\"#f0f0f0\"><b>选择配码</b> <input type=\"button\" value=\"新增配码\" onclick=\"window.location.href='?_m=".$_m."&dpid=".$dpid."&iid=".$iid."&obj=".$obj."&_a=add'\"></td></tr>";
|
|
|
|
$kh=get_db_msg("select * from ".$table_pre."kh where id='".$iid."'");
|
|
$json_data.="\"size\":\"".$kh["size"]."\",";
|
|
|
|
$json_data.="\"obj\":\"".$obj."\",";
|
|
//取得装箱数
|
|
$q1="select num from ".$table_pre."gz where cate='zxs' and (dj='".$m_client["username"]."' or dj='') and kh='".$m_kh["no"]."' order by num";
|
|
//echo $q1;
|
|
$r1=$db->query($q1);
|
|
$sql_pm="";
|
|
$str_zxs="";
|
|
while($m1=$db->fetch_array($r1)){
|
|
$sql_pm.="num='".$m1["num"]."' or ";
|
|
//$str_zxs.="{\"zxs\":\"".$m1["num"]."\"},";
|
|
$str_zxs.=$m1["num"].",";
|
|
}
|
|
if($str_zxs){
|
|
$str_zxs=deel_end($str_zxs);
|
|
}
|
|
$json_data.="\"zxs\":\"".$str_zxs."\",";
|
|
if($sql_pm)
|
|
$sql_pm=" and (".substr($sql_pm,0,-4).")";
|
|
//读取配码信息
|
|
//配码等级一样,店铺id一样或者店铺id为空(适合所有店铺的配码)
|
|
$q="select * from ".$table_pre."size_pm where (uid='".$dpid."' or uid='') and pm_dj='".$m_kh["pm_dj"]."' ".$sql_pm." order by id";
|
|
//echo $q;
|
|
$r=$db->query($q);
|
|
$content_pm="<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" width=\"100%\" bgcolor=\"#eeeeee\">";
|
|
$i=0;
|
|
$size_ws_kh=count(explode(",",$m_kh["size"]));
|
|
$str_pm="";
|
|
while($m=$db->fetch_array($r)){
|
|
$size_ws=count(explode(":",$m["gz"]));
|
|
//echo $size_ws."|".$size_ws_kh."-<br>";
|
|
if($size_ws==$size_ws_kh){
|
|
$is_edit=($m["uid"]==$dpid)?"y":"n";
|
|
$str_pm.="{\"is_edit\":\"".$is_edit."\",\"id\":\"".$m["id"]."\",\"title\":\"".$m["title"]."\",\"gz\":\"".$m["gz"]."\",\"num\":\"".$m["num"]."\"},";
|
|
|
|
$content_pm.="<tr bgcolor=\"#ffffff\"><td onclick=\"check_pm('".$obj."','".$m["id"]."|".$m["title"]."|".$m["gz"]."')\"><input type='radio' name='pm_id' value='".$m["id"]."|".$m["gz"]."'>".$m["title"]."</td><td>".$m["gz"]."=".$m["num"]."</td><td width=\"110\"><input type=\"button\" value=\"修改\" style='width:50px;' onclick=\"window.location.href='?_m=".$_m."&dpid=".$dpid."&iid=".$iid."&obj=".$obj."&id=".$m["id"]."&_a=add'\"".$is_edit."> <input type=\"button\" value=\"删除\" style='width:50px;' onclick=\"d_confirm('确认删除吗?','?_m=".$_m."&dpid=".$dpid."&iid=".$iid."&obj=".$obj."&id=".$m["id"]."&_a=del')\"".$is_edit."></td></tr>";
|
|
$i++;
|
|
}
|
|
}
|
|
if($str_pm){
|
|
$str_pm=deel_end($str_pm);
|
|
}
|
|
$json_data.="\"pm\":[".$str_pm."],";
|
|
$content_pm.="</table>";
|
|
if($i==0)
|
|
$content_pm="暂无您的配码信息,请先新增。";
|
|
$content.="<tr><td align=\"left\">".$content_pm."</td></tr>";
|
|
//
|
|
$content.="</table>";
|
|
break;
|
|
}
|
|
|
|
$json_data=substr($json_data,0,-1)."}";
|
|
echo $json_data;
|
|
?>
|