1 Star 0 Fork 1

yihoc/WEBWMS

forked from gujiejing/WEBWMS 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
slasnformf.php 5.75 KB
一键复制 编辑 原始数据 按行查看 历史
wisdom 提交于 2017-11-03 23:31 . upupup new alll
<?php
header('Content-type: text/html; charset=utf-8');
require_once('connDB.php');
//$dbc = mysql_connect("localhost","root","root");
//$GLOBALS['dbc'] = $dbc; //$GLOBALS['checkTF'] = false;
//global $checkTF;
$checkTF = 0;
//echo "checkTF->".$checkTF."<br/>";
//var url="slasnformf.php?ID="+id1+"&cancelType=1";
if((isset($_GET['ID']))&&
(isset($_GET['cancelType']))&&
($_GET['cancelType']=="1"))
{
$id=$_GET['ID'];
//echo "abc";
$sql="SELECT * FROM `asnd` WHERE `ID` = '$id'";
$sql1="SELECT SUM( UOMNUM ) as tqty FROM `asnd` WHERE `ID` = '$id'";
$result1=mysql_query($sql,$dbc);
$row_Rec=mysql_fetch_assoc($result1);
$result2=mysql_query($sql1,$dbc);
$row_Rec2=mysql_fetch_assoc($result2);
/*while($row_Rec=mysql_fetch_assoc($result)){
$ASNID = $row_Rec[];
}*/
$ASNID = $row_Rec['ASNID'];
$tqty1=$row_Rec2['tqty'];
$chkasnqty=checkASNIDQTY($ASNID,$tqty1,$dbc);
//echo $chkasnqty;
if($chkasnqty==0){
$obj->result = 0;
$obj->reason = "ASN: $ASNID 已经被部分发货";
echo json_encode($obj);
return;
}
$sql="UPDATE `webwms`.`asnh` SET `ASNState` = 'CREATE' WHERE `asnh`.`ID` =$id;";
mysql_query($sql,$dbc);
$sql="DELETE FROM `webwms`.`lotxloc` WHERE `lotxloc`.`ASNID` = '$ASNID';";
mysql_query($sql,$dbc);
$obj->result = 1;
$obj->reason = "ASN: $ASNID 取消收货成功";
echo json_encode($obj);
return;
}
if((isset($_GET['ID']))&&
(isset($_GET['cancelType']))&&
($_GET['cancelType']=="2"))
{
//echo "abc";
$id=$_GET['ID'];
$sql="SELECT * FROM `asnd` WHERE `ID` = '$id'";
$result1=mysql_query($sql,$dbc);
$row_Rec=mysql_fetch_assoc($result1);
$ASNID = $row_Rec['ASNID'];
$sql="UPDATE `webwms`.`asnh` SET `ASNState` = 'CREATE' WHERE `asnh`.`ID` =$id;";
mysql_query($sql,$dbc);
$sql="DELETE FROM `webwms`.`lotxloc` WHERE `lotxloc`.`ASNID` = '$ASNID';";
mysql_query($sql,$dbc);
$obj->result = 1;
$obj->reason = "ASN: $ASNID 取消收货成功";
echo json_encode($obj);
return;
}
function checkASNIDQTY($ASNID,$tqty1,$dbc){
$sql="SELECT SUM( QTY ) AS tqty FROM `lotxloc` WHERE `ASNID` = '$ASNID'";
$result3=mysql_query($sql,$dbc);
$row_Rec3=mysql_fetch_assoc($result3);
$tqty2 = $row_Rec3['tqty'];
if($tqty2==$tqty1){
return 1;
}else{
return 0;
}
}
//echo 'slasnformf.php->OK';
function checkID($id){
$sql="SELECT * FROM asnh ".
"LEFT JOIN asnd ON asnh.ID = asnd.ID ".
"WHERE asnh.ID =$id ";
//echo $sql;
$dbc = mysql_connect("localhost","root","root");
mysql_select_db("webwms",$dbc);
$result = mysql_query($sql,$dbc);
$row_Rec = mysql_fetch_assoc($result);
$totalRows = mysql_num_rows($result);
//echo $GLOBALS['checkTF'];
if(!($totalRows>0)){
$GLOBALS['checkTF'] = 0;
echo "checkTF->".$checkTF."<br/>";
return;
}
//echo $GLOBALS['checkTF'];
if(empty($row_Rec)){
$GLOBALS['checkTF'] = 0;
echo "checkTF->".$checkTF."<br/>";
return;
}
//echo $GLOBALS['checkTF'];
do{
if(empty($row_Rec['SKU'])){
echo $row_Rec['SKU'];
echo "checkTF->SKU ".$GLOBALS['checkTF']."<br/>";
$GLOBALS['checkTF'] = 0;
return;
}
if(empty($row_Rec['UOMNUM'])){
$GLOBALS['checkTF'] = 0;
return;
}
if(empty($row_Rec['LOC'])){
$GLOBALS['checkTF'] = 0;
return;
}
}while($row_Rec = mysql_fetch_assoc($result));
$GLOBALS['checkTF'] = 1;
//echo $GLOBALS['checkTF'];
}
function receiveCargo($id){
$sql="SELECT * FROM asnh ".
"LEFT JOIN asnd ON asnh.ID = asnd.ID ".
"WHERE asnh.ID =$id ";
//echo $sql;
$dbc = mysql_connect("localhost","root","root");
mysql_select_db("webwms",$dbc);
$result = mysql_query($sql,$dbc);
$row_Rec = mysql_fetch_assoc($result);
do{
/*echo "SKU->".$row_Rec['SKU']
.",UOMNUM->".$row_Rec['UOMNUM']
.",ASNID->".$row_Rec['ASNID']
.",VEDCODE->".$row_Rec['nID']
.",LOC->".$row_Rec['LOC']."<br/>"; */
$LOTID = getLOTID($row_Rec['nID']);
$sql="INSERT INTO `webwms`.`lotxloc` ("
."`Id` ,"
."`LOTID` ,"
."`SKU` ,"
."`QTY` ,"
."`ASNID` ,"
."`VCODE` ,"
."`LOC` "
.")VALUES ("
."NULL , "
."'$LOTID', "
."'".$row_Rec['SKU']."', "
."'".$row_Rec['UOMNUM']."', "
."'".$row_Rec['ASNID']."', "
."'".$row_Rec['nID']."', "
."'".$row_Rec['LOC']."'"
.");";
//echo $sql."<br/>";
mysql_query($sql,$dbc);
}while($row_Rec = mysql_fetch_assoc($result));
$sql="UPDATE `webwms`.`asnh` SET `ASNState`='RECEIVED' WHERE `asnh`.`ID` =$id;";
mysql_query($sql,$dbc);
}
/*
UPDATE `webwms`.`asnh` SET `ASNState` = 'FINISH' WHERE `asnh`.`ID` =319;
INSERT INTO `webwms`.`lotxloc` (
`Id` ,`LOTID` ,`SKU` ,`QTY` ,`ASNID` ,`VCODE` ,`LOC` ,`REMARK1`
)VALUES (
NULL , '111', 'aaa', '22', 'aaa', 'bbb', 'cccc');
*/
//-------------------------------------------------------------------------------------------
//---MAIN FUNCTION---------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------
if(isset($_GET['ID'])){
$id = $_GET['ID'];
//echo 'ID=>'.$id."<br/>";
checkID($id);
//echo $checkTF;
if($checkTF==0){
//$arr = array('result'=>0,'reason'=>'数据不全');
$obj->result = 0;
$obj->reason = '数据不全';
echo json_encode($obj);
return;
}else if($checkTF==1)
{
//echo 'start receive<br/>';
receiveCargo($id);
$obj->result = 1;
$obj->reason = '收货完成';
echo json_encode($obj);
return;
}
}
/**
<!--
SELECT * FROM asnh
LEFT JOIN asnd ON asnh.ID = asnd.ID
WHERE asnh.ID =319
if (empty($var)) {
echo '$var is either 0 or not set at all';
}
-->
*/
?>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/yihoc/WEBWMS.git
git@gitee.com:yihoc/WEBWMS.git
yihoc
WEBWMS
WEBWMS
master

搜索帮助