代码拉取完成,页面将自动刷新
同步操作将从 gujiejing/WEBWMS 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<?php
header('Content-type: text/html; charset=utf-8');
require_once('connDB.php');
if(!isset($_SESSION)){
session_start();
}
//$_SESSION["SKUQTY"]="";
$NewsoID = " ";
$OldsoID = " ";
$RETIME = time();
//echo $_GET['id'];
$invErrInfo="";
$allSkuQty="";
if(isset($_GET['idsh'])&&isset($_GET['show'])){
//echo "abc";
$id=$_GET['idsh'];
$sql="SELECT `order_doc_header` . * ,
`order_doc_detail` . * ,
`sku`.`skucn`
FROM `order_doc_header` INNER JOIN `order_doc_detail`
ON `order_doc_header`.`id` = `order_doc_detail`.`id`
LEFT JOIN `sku` ON `order_doc_detail`.`sku` = `sku`.`skuid`
WHERE `order_doc_header`.`id` =$id";
$result=mysql_query($sql,$dbc);
//$row_Rec=mysql_fetch_assoc($result);
$table1='<table border="1" cellpadding="0" cellspacing="0" width="512">';
$table1=$table1.'<tr><td>商品ID</td><td>商品名称</td><td>购买数量</td><td>总价</td></tr>';
while($row_Rec=mysql_fetch_assoc($result)){
$table1=$table1.'<tr>
<td>'.$row_Rec['sku'].'</td>
<td>'.$row_Rec['skucn'].'</td>
<td>'.$row_Rec['buyqty'].'</td>
<td>'.$row_Rec['totalPrice'].'</td>
</tr>';
}
$table1=$table1.'</table>';
//echo $table1;
$obj->result=1;
$obj->status=1;
$obj->table=$table1;
echo json_encode($obj);
return;
}
if((isset($_GET['CreateASN']))&&($_GET['CreateASN']=="true")){
if(!empty($_SESSION['SKUQTY'])){
$str1 = $_SESSION['SKUQTY'];
//echo $str1;
$arr1 = Array();
$arr1 = explode(",",$str1);
//print_r($arr1);
//echo "<br>";
while(list($aaa,$vvv)=each($arr1)){
//echo $aaa.$vvv;
$arr2=Array();
$arr2=explode("|",$vvv);
//echo $arr2[0];
//echo "<br>";
//echo $arr2[1];
createASN($arr2[0],$arr2[1],$dbc);
}
}
return;
}
//received
function createASN($sku1,$qty1,$dbc){
$sql="SELECT `sku`.* FROM `sku` WHERE `sku`.`skuid` = '$sku1';";
$result=mysql_query($sql,$dbc);
$row_Rec=mysql_fetch_assoc($result);
$custid=$row_Rec['custid'];
$skucn=$row_Rec['skucn'];
$timeTmp1 = date('Y-m-d h:i:s',time());
$RETIME = time();
$sql = "INSERT INTO asnh ( ID, ASNID, ASNState,CUSTID,REVTIME)VALUES(NULL, '$RETIME', 'CREATE','$custid','$timeTmp1')";
mysql_query($sql,$dbc);
$sql="SELECT * FROM asnh WHERE ASNID = '$RETIME'";
$result=mysql_query($sql,$dbc);
$row_Rec=mysql_fetch_assoc($result);
//echo $row_Rec['ID'];
$OldAsnID=$row_Rec['ID'];
$NewAsnID=getASNID($OldAsnID);
$sql = "UPDATE asnh SET ASNID = '$NewAsnID' WHERE asnh.ASNID ='$RETIME'";
mysql_query($sql,$dbc);
$ID = $OldAsnID;
$ASN= $NewAsnID;
$sql = "SELECT * FROM asnd WHERE ID =$ID";
$row_Rec1 = mysql_query($sql,$dbc);
$res_Row=mysql_num_rows($row_Rec1);
$res_Row = $res_Row +1;
$sql= "INSERT INTO webwms.asnd(nID,ID,ASNID,ITEMNO,SKU,UOMNUM,LOC,SKUCN)".
"VALUES(NULL, '$ID', '$ASN', $res_Row, '$sku1', '$qty1', 'aaa', '$skucn')";
mysql_query($sql,$dbc);
$obj->result=1;
$obj->status=1;
$obj->reasons="create new ASN is: ".$ASN;
echo json_encode($obj);
return;
}
if(isset($_GET['id'])){
$id=$_GET['id'];
$sql="SELECT `order_doc_header` . * ,
`order_doc_detail` . * ,
`sku`.`skucn`
FROM `order_doc_header`
INNER JOIN `order_doc_detail` ON `order_doc_header`.`id` = `order_doc_detail`.`id`
LEFT JOIN `sku` ON `order_doc_detail`.`sku` = `sku`.`skuid`
WHERE `order_doc_header`.`id` =$id";
$result = mysql_query($sql,$dbc);
$row_Rec=mysql_fetch_assoc($result);
$sql="INSERT INTO `webwms`.`soh` (`ID`, `SOID`, `SOState`)
VALUES(NULL,$RETIME,'CREATE')";
mysql_query($sql,$dbc);
$sql="SELECT * FROM `soh` WHERE `SOID` = '$RETIME'";
$resultCreate=mysql_query($sql,$dbc);
$row_Rec1=mysql_fetch_assoc($resultCreate);
$OldsoID = $row_Rec1['ID'];
$NewsoID = getSOID($OldsoID);
$sql="UPDATE `webwms`.`soh` SET `SOID`= '$NewsoID',
`CustomerID` = '".$row_Rec['customerID']."',
`ShipTo` = '".$row_Rec['sendAddress']."',
`InvoiceNo` = '".$row_Rec['OrderID']."' WHERE `soh`.`SOID` ='$RETIME' ";
//echo $sql;
mysql_query($sql,$dbc);
$sql = "SELECT * FROM `soh` WHERE `SOID` ='$NewsoID'";
$result3=mysql_query($sql,$dbc);
$row_Rec2=mysql_fetch_assoc($result3);
$ID1=$row_Rec2['ID'];
$SOID1=$row_Rec2['SOID'];
$i1=1;
do{
$sku1=$row_Rec['sku'];
$buyqty1=$row_Rec['buyqty'];
$sql="INSERT INTO `webwms`.`sod` (
`ID` ,`SOID` ,`ITEMNO` ,`SKU` ,`SKUCN` ,`UOMNUM` , `UNITPRICE` ,`TOTALPRICE` )
VALUES ($ID1, '$SOID1',
".$i1++.",
'".$row_Rec['sku']."',
'".$row_Rec['skucn']."',
".$row_Rec['buyqty'].",
".$row_Rec['unitPrice'].",
".$row_Rec['totalPrice'].");";
//echo $sql;
mysql_query($sql,$dbc);
checkInv($sku1,$buyqty1,$dbc);
}while($row_Rec=mysql_fetch_assoc($result));
$sql="UPDATE `webwms`.`order_doc_header` SET `SOID` = '$NewsoID'
WHERE `order_doc_header`.`id` =$id;";
//echo $sql;
mysql_query($sql,$dbc);
$obj->result=1;
if(empty($invErrInfo)){
$obj->status1=1;
}else{
$obj->status1=2;
}
$obj->id1=$id;
$obj->respText="GET SO ID complete";
$obj->SOID=$SOID1;
$obj->invErrInfo=$invErrInfo;
echo json_encode($obj);
$allSkuQty=rtrim($allSkuQty,",");
$_SESSION['SKUQTY']=$allSkuQty;
return;
}
function checkInv($sku1,$buyqty1,$dbc){
$sql2="SELECT SUM(`QTY`) AS QTY FROM `showinv2`
WHERE `SKU` = '$sku1' AND `isHold` =0";
$result4=mysql_query($sql2,$dbc);
$row_Rec3=mysql_fetch_assoc($result4);
$qty2=$row_Rec3['QTY'];
if($buyqty1>$qty2){
$invErrInfo2=$GLOBALS['invErrInfo'];
$invErrInfo2=$invErrInfo2.$sku1.'的库存不足采购数量为'.$buyqty1.',';
$GLOBALS['invErrInfo']=$invErrInfo2;
$allSkuQty1=$GLOBALS['allSkuQty'];
$allSkuQty1=$allSkuQty1.$sku1."|".$buyqty1.",";
$GLOBALS['allSkuQty']=$allSkuQty1;
}else{}
}
/*SELECT SUM(`QTY`) FROM `showinv2`
WHERE `SKU` = 'hjcc003' AND `isHold` =0*/
?>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。