7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
279 lines
11 KiB
PHP
279 lines
11 KiB
PHP
<?php
|
|
//if(THIS_IN!="edt_ipad")
|
|
//exit("错误的访问!");
|
|
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
|
require "../config.php";
|
|
include "../../tmpl/config.php";
|
|
require "../../ipad/include/function.php";
|
|
require "../../ipad/include/db_mysql.php";
|
|
$db=new DB_Sql;
|
|
$db->connect($dbhost,$dbuser,$dbpw,$dbname,"p");
|
|
$iid=$_GET["iid"];
|
|
$dpid=$_GET["dpid"];
|
|
$obj=$_GET["obj"];
|
|
$_a=$_GET["_a"];
|
|
$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."'");
|
|
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{
|
|
$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="";
|
|
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"].":";
|
|
}
|
|
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>";
|
|
//$url=$_SERVER["PHP_SELF"]."?_a=save_add";
|
|
$content.="<form name='form_pm' id='form_pm' action='".$_SERVER["PHP_SELF"]."?_a=save_add' 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>";
|
|
break;
|
|
case "save_add":
|
|
$title=$_POST["title"];
|
|
$dpid=$_POST["dpid"];
|
|
$iid=$_POST["iid"];
|
|
$obj=$_POST["obj"];
|
|
$id=$_POST["id"];
|
|
$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."'");
|
|
$arr_size=explode(",",$m_kh["size"]);
|
|
for($j=0;$j<count($arr_size);$j++){
|
|
$v="gz_".$arr_size[$j];
|
|
$$v=$_POST[$v];
|
|
}
|
|
$title=trim($title);
|
|
if(strstr($title,"|"))
|
|
alert_and_back("非法字串“|”,请检查!");
|
|
//
|
|
$num=0;
|
|
//检查是否符合尺码数量
|
|
$gz="";
|
|
|
|
for($i=0;$i<count($arr_size);$i++){
|
|
$var="gz_".$arr_size[$i];
|
|
$arr_gz[$i]=$$var;
|
|
$num+=$$var;
|
|
if($$var){
|
|
$gz.=$$var.":";
|
|
}else{
|
|
$gz.="0:";
|
|
}
|
|
}
|
|
if($gz)
|
|
$gz=substr($gz,0,-1);
|
|
if(count($arr_size)!=count($arr_gz))
|
|
alert_and_back("对不起,配码数与尺码数不符,请检查!");
|
|
//检查是否符合装箱数
|
|
$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("对不起,配码不符合装箱数,请检查!");
|
|
}
|
|
//
|
|
//检查是否存在
|
|
$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="pm.php?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=utf-8\"></head><body><script> alert('保存失败!(该配码已经存在)');window.parent.set_pm_div_h(".$pm_rows.",'".$obj."');window.parent.location.href='".$rurl."'; </script></body></html>";
|
|
exit();
|
|
}
|
|
$qy_uid=get_qy_id($m_client["path"]);
|
|
//echo $gz."-".$num."<br>";
|
|
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("对不起,该配码已经使用,不允许修改!");
|
|
}
|
|
$q1="update ".$table_pre."size_pm set title='".$title."',gz='".$gz."',num='".$num."' where id='".$id."'";
|
|
$db->query($q1);
|
|
}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);
|
|
}
|
|
$rurl="pm.php?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=utf-8\"></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("对不起,该配码已经使用,不允许删除!");
|
|
$q="delete from ".$table_pre."size_pm where id='".$id."'";
|
|
$db->query($q);
|
|
$rurl="pm.php?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=utf-8\"></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='pm.php?dpid=".$dpid."&iid=".$iid."&obj=".$obj."&_a=add'\"></td></tr>";
|
|
//取得装箱数
|
|
$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);
|
|
$sql_pm="";
|
|
while($m1=$db->fetch_array($r1)){
|
|
$sql_pm.="num='".$m1["num"]."' or ";
|
|
}
|
|
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";
|
|
$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"]));
|
|
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)?"":" disabled";
|
|
$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='pm.php?dpid=".$dpid."&iid=".$iid."&obj=".$obj."&id=".$m["id"]."&_a=add'\"".$is_edit."> <input type=\"button\" value=\"删除\" style='width:50px;' onclick=\"d_confirm('确认删除吗?','pm.php?dpid=".$dpid."&iid=".$iid."&obj=".$obj."&id=".$m["id"]."&_a=del')\"".$is_edit."></td></tr>";
|
|
$i++;
|
|
}
|
|
}
|
|
$content_pm.="</table>";
|
|
if($i==0)
|
|
$content_pm="暂无您的配码信息,请先新增。";
|
|
$content.="<tr><td align=\"left\">".$content_pm."</td></tr>";
|
|
//
|
|
$content.="</table>";
|
|
break;
|
|
}
|
|
?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta content="telephone=no" name="format-detection" />
|
|
<meta name="viewport" content="user-scalable=yes,initial-scale=1,maximum-scale=3.0,minimum-scale=1" />
|
|
<title>--</title>
|
|
<style>
|
|
body,input,td,select,div,li,ul,textarea,form {
|
|
font-family:宋体;FONT-SIZE:14px;
|
|
}
|
|
</style>
|
|
<script>
|
|
function d_confirm(msg,url){
|
|
var a=confirm(msg);
|
|
if(a==true){
|
|
window.location.href=url;
|
|
}
|
|
}
|
|
function check_pm(obj,v){
|
|
//alert(obj);
|
|
window.parent.check_pm(obj,v);
|
|
}
|
|
</script>
|
|
</head>
|
|
<body style="margin:0px;padding:0px;background-color:#ffffff;">
|
|
<?php echo $content; ?>
|
|
</body>
|
|
</html>
|