代码拉取完成,页面将自动刷新
同步操作将从 gujiejing/WEBWMS 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<?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';
}
-->
*/
?>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。