This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
EDT/admin/debug/alter_size_not.php
T
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

263 lines
9.3 KiB
PHP

<?php
//-------------------------------------------------------自动计算不予下单尺码,支持童装和文胸
//--2019/11/29 by hehe
//对数组根据值排序,并且重新计算索引
function arr_px1($arr){
asort($arr);//排序
$k2=0;
//索引排序
$arr1=array();
foreach($arr as $k1 => $v1){
$arr1[$k2]=$v1;
$k2++;
}
return $arr1;
}
require "../config.php";
include "../../tmpl/config.php";
require THIS_FILE_ROOT."/include/function.php";
require THIS_FILE_ROOT."/include/db_mysql.php";
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//-------------------------------mysql connect
$msg="";
$db=new DB_Sql;
$db->connect($dbhost,$dbuser,$dbpw,$dbname,"p");
$is_submit=$_POST["is_submit"];
$is_multi_price=get_set("is_multi_price");
//文胸
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;
}
//童装
if($child_sizegroup_title){
$tmp=get_db_msg("select id from ".$table_pre."keyword where cate='size' and title='".$child_sizegroup_title."' limit 0,1");
$child_sizegroup_id=$tmp["id"];
}else{
$child_sizegroup_id=0;
}
if($is_submit=="y"){
$content=$_POST["content"];
$arr=explode("\n",$content);
$arr_kh=array();
$error_kh=$error_kh=array();
//
for($i=0;$i<count($arr);$i++){
$str1=$arr[$i];
$arr1=explode(" ",$str1);
$kh=trim($arr1[0]);
$color=trim($arr1[1]);
$bx=trim($arr1[2]);
$size_group=trim($arr1[3]);
$size=trim($arr1[4]);
if($kh){
$arr_kh[$kh][]=array($color,$bx,$size_group,$size);
//echo $i.":".$kh."-".$color."-".$bx."-".$size_group."-".$size."<br>";
}
}
//清空不予下单表
//$db->query("truncate table ".$table_pre."size_not;");
//计算尺码
foreach($arr_kh as $kh => $arr1){
$m_kh=get_db_msg("select id,no,size_group from ".$table_pre."kh where no='".$kh."'");
$khid=$m_kh["id"];
if($khid>0){
$db->query("delete from ".$table_pre."size_not where kh='".$kh."'");//清空该款的不予下单表
$j=count($arr1);
$arr_color=$arr_bx=$arr_size_group=$arr_size=array();
for($k=0;$k<$j;$k++){
//
$arr_color[$k]=$arr1[$k][0];
$arr_bx[$k]=$arr1[$k][1];
$arr_size_group[$k]=$arr1[$k][2];
$arr_size[$k]=$arr1[$k][3];
}
if($bx_sizegroup_id==$m_kh["size_group"] || $child_sizegroup_id==$m_kh["size_group"]){
//---------------------文胸或者童装
if($j>1){
$size_all_bx=array();//到杯型的全尺码
$kh_bx=array();//该款的所有杯型
$arr_size_no=array();
for($i1=0;$i1<count($arr_bx);$i1++){
$size_all_bx[$arr_bx[$i1]]=array();//初始化数组
}
for($i1=0;$i1<count($arr_size);$i1++){
$tmp=get_db_msg("select id from ".$table_pre."keyword where cate='size' and title='".$arr_size_group[$i1]."'");
$size_group_id=$tmp["id"];
$arr_tmp=explode(",",$arr_size[$i1]);
for($i2=0;$i2<count($arr_tmp);$i2++){
$tmp=get_db_msg("select no from ".$table_pre."size where iid='".$size_group_id."' and title='".$arr_tmp[$i2]."'");
$arr_size_no[$i1][$i2]=$tmp["no"];//尺码名称转换成尺码编码
if(!in_array($tmp["no"],$size_all_bx[$arr_bx[$i1]]))
$size_all_bx[$arr_bx[$i1]][]=$tmp["no"];
}
if(!in_array($arr_bx[$i1],$kh_bx)){
$kh_bx[]=$arr_bx[$i1];
}
}
foreach($size_all_bx as $bx => $arr_s){
$size_all_bx[$bx]=arr_px1($arr_s);
}
//print_r($size_all_bx);
foreach($size_all_bx as $bx => $arr_s){
$check=get_db_msg("select id from ".$table_pre."size_bx where no='".$m_kh["no"]."' and bx='".$bx."'");
if($check["id"]>0){
$q="update ".$table_pre."size_bx set size='".arr_to_str($arr_s)."' where no='".$m_kh["no"]."' and bx='".$bx."'";
}else{
$q="insert ".$table_pre."size_bx (no,bx,size) values ('".$m_kh["no"]."','".$bx."','".arr_to_str($arr_s)."')";
}
$db->query($q);//更新size_bx表的尺码
}
//------检查是否存在遗漏的杯型
$arr_color_bx=array();
for($i3=0;$i3<count($arr_color);$i3++){
$arr_color_bx[$arr_color[$i3]][]=$arr_bx[$i3];
}
foreach($arr_color_bx as $color1 => $arr_bx1){
for($i4=0;$i4<count($kh_bx);$i4++){
if(!in_array($kh_bx[$i4],$arr_bx1)){
$q="insert ".$table_pre."size_not (kh,color,bx,size) values ('".$kh."','".$color1."','".$kh_bx[$i4]."','".arr_to_str($size_all_bx[$kh_bx[$i4]])."')";
$db->query($q);
//echo $q."<br>";
$right_kh[]=$kh."-".$color1."-".$kh_bx[$i4];
}
}
}
//print_r($kh_bx);
//echo "<Br>";
//print_r($arr_color_bx);
for($i3=0;$i3<count($arr_color);$i3++){
//设置不予下单尺码
$size_not="";
$size_all_tmp=$size_all_bx[$arr_bx[$i3]];
for($j3=0;$j3<count($size_all_tmp);$j3++){
if(!in_array($size_all_tmp[$j3],$arr_size_no[$i3]))
$size_not.=$size_all_tmp[$j3].",";
}
if($size_not){
$size_not=substr($size_not,0,-1);
$check=get_db_msg("select id from ".$table_pre."size_not where kh='".$kh."' and color='".$arr_color[$i3]."' and bx='".$arr_bx[$i3]."'");
if($check["id"]>0){
$q="update ".$table_pre."size_not set size='".$size_not."' where id='".$check["id"]."'";
}else{
$q="insert ".$table_pre."size_not (kh,color,bx,size) values ('".$kh."','".$arr_color[$i3]."','".$arr_bx[$i3]."','".$size_not."')";
}
//echo $q."<br>";
$db->query($q);//设置不予下单尺码
$right_kh[]=$kh."-".$arr_color[$i3]."-".$arr_bx[$i3];
}
}
}
}else{
//---------------------非文胸
if($j>1){
//
$arr_size1=array_unique($arr_size);
if(count($arr_size1)>1){
//需要设置不予下单
$size_all=array();//到款的全尺码
$arr_size_no=array();
for($i1=0;$i1<count($arr_size);$i1++){
//取得尺码组id
$tmp=get_db_msg("select id from ".$table_pre."keyword where cate='size' and title='".$arr_size_group[$i1]."'");
$size_group_id=$tmp["id"];
$arr_tmp=explode(",",$arr_size[$i1]);
for($i2=0;$i2<count($arr_tmp);$i2++){
$tmp=get_db_msg("select no from ".$table_pre."size where iid='".$size_group_id."' and title='".$arr_tmp[$i2]."'");
$arr_size_no[$i1][$i2]=$tmp["no"];//尺码名称转换成尺码编码
if(!in_array($tmp["no"],$size_all))
$size_all[]=$tmp["no"];
}
}
$size_all=arr_px1($size_all);//排序
//print_r($size_all);
$q="update ".$table_pre."kh set size='".arr_to_str($size_all)."' where id='".$khid."'";
$db->query($q);//更新款号表的尺码
for($i3=0;$i3<count($arr_color);$i3++){
//设置不予下单尺码
$size_not="";
for($j3=0;$j3<count($size_all);$j3++){
if(!in_array($size_all[$j3],$arr_size_no[$i3]))
$size_not.=$size_all[$j3].",";
}
if($size_not){
$size_not=substr($size_not,0,-1);
$check=get_db_msg("select id from ".$table_pre."size_not where kh='".$kh."' and color='".$arr_color[$i3]."' and bx='".$arr_bx[$i3]."'");
if($check["id"]>0){
$q="update ".$table_pre."size_not set size='".$size_not."' where id='".$check["id"]."'";
}else{
$q="insert ".$table_pre."size_not (kh,color,bx,size) values ('".$kh."','".$arr_color[$i3]."','".$arr_bx[$i3]."','".$size_not."')";
}
//echo $q."<br>";
$db->query($q);//设置不予下单尺码
$right_kh[]=$kh."-".$arr_color[$i3];
}
}
//echo $kh.":";
//print_r($size_all);
}
}
}
}else{
$error_kh[]=$kh;//款号有误
}
}
$msg="";
if(count($error_kh)>0){
$msg.="以下款号有误:".arr_to_str($error_kh).";<br>";
}
if(count($right_kh)>0){
$msg.="以下款设置成功:".arr_to_str($right_kh).";<br>";
}
}
?>
<!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" />
<title>自动计算不予下单尺码</title>
<style>
BODY{
font-family:宋体;FONT-SIZE:12px;margin:0px;padding:0px;
}
a,a:link,a:visited,a:active {
text-decoration:none;COLOR: #0000ff;FONT-SIZE:12px;
}
a:hover {
TEXT-DECORATION: underline;COLOR: #aaaa9f;FONT-SIZE:12px;
}
body,input,td,select,div,li,ul,textarea,form {
font-family:宋体;
FONT-SIZE:12px;
}
.wrong{
color:#ff0000;font-weight:bold;
}
</style>
</head>
<body>
<br />
<table width="80%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#cccccc">
<form name="form1" action="" method="post">
<input type="hidden" name="is_submit" value="y">
<tr>
<td align="center" bgcolor="#f0f0f0"><b>自动计算不予下单尺码(按款计算)</b></td>
</tr>
<tr>
<td align="left" bgcolor="#ffffff" style="line-height:25px;">格式说明(字段间用制表符分割):款号,颜色代码,规格或杯型(没有留空),尺码组名称,尺码名称(逗号分隔);多条记录请回车。<Br>
<textarea name="content" style="width:100%;" rows="20"><?php echo $content; ?></textarea></td>
</tr>
<tr>
<td align="center" bgcolor="#f0f0f0"><input type="submit" value=" 提 交 "></td>
</tr>
<?php
if($msg){
echo "<tr><td align=\"left\" bgcolor=\"#ffffff\" valign=\"top\" style=\"line-height:150%;\">".$msg."</td></tr>";
}
?>
</form>
</table>
</body>
</html>