1 Star 0 Fork 1

yihoc/WEBWMS

forked from gujiejing/WEBWMS 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
orderf.php 5.99 KB
一键复制 编辑 原始数据 按行查看 历史
wisdom 提交于 2017-11-03 23:31 . upupup new alll
<?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*/
?>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/yihoc/WEBWMS.git
git@gitee.com:yihoc/WEBWMS.git
yihoc
WEBWMS
WEBWMS
master

搜索帮助