<? include("connect.php"); $pOrderValue = 0; $sql3="select * from sell_order where type_sale = 2 and order_status = 2 order by sell_order_id ASC"; $res3=mysql_query($sql3); while($show3=mysql_fetch_array($res3)){ $loadStock2 = "select * from stock"; $qtyStock2 = mysql_query($loadStock2) or die(mysql_error); while($rowStock2=mysql_fetch_array($qtyStock2)){ $loadDetail="select * from sell_detail WHERE order_id='$show3[sell_order_id]' and P_ID = '$rowStock2[P_ID]' "; $roDetail=mysql_query($loadDetail) or die(mysql_error()); while($rowDetail=mysql_fetch_array($roDetail)){ $pOrderValue = $pOrderValue+$rowDetail[sale_qty]; $updateStock2 = "UPDATE stock SET qty_order = '$pOrderValue' "; $updateStock2 .= "WHERE P_ID = '$rowDetail[P_ID]'"; $result2 = mysql_query($updateStock2) or die ($result2); } } } ?> <? include("connect.php"); $isCut = true; $loadDetail="select * from sell_detail WHERE order_id='$sell_order_id'"; if($rDetail=mysql_query($loadDetail)){ while($row=mysql_fetch_array($rDetail)){ $P_ID = $row[P_ID]; $lValue = $row[sale_qty]; $strSelect2 = "SELECT * FROM stock WHERE P_ID = '$P_ID'"; $reSelect2 = mysql_query($strSelect2); if($reSelect2){ $readerSelect2=mysql_fetch_array($reSelect2); $reTotle2 = $readerSelect2[qty]-$lValue; //$reTotalOrder2 = $readerSelect2[qty_order]-$lValue; if($reTotle2 < 0){ $isCut = false; break; } } } } if($isCut == false) { $loadPro = "SELECT * FROM product WHERE P_ID = '$P_ID'"; $rePro = mysql_query($loadPro); $readerPro=mysql_fetch_array($rePro); $qtyRe = $lValue-$readerSelect2[qty]; $word = "จำนวนสั่งซื้อเกินจำนวนคงเหลือในสต็อก ".$readerPro[P_ID]." ".$qtyRe." " ; echo("<script language='javascript'> window.alert('$word'); window.location='stock_detail.php'; </script>"); }else{ $sqlEdit = "UPDATE sell_order SET order_status = '3'"; $sqlEdit .= "WHERE sell_order_id = '$sell_order_id'"; $result = mysql_query($sqlEdit) or die ($result); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ $loadDetail="select * from sell_detail WHERE order_id='$sell_order_id'"; if($rDetail=mysql_query($loadDetail)){ while($row=mysql_fetch_array($rDetail)){ //================================================================ $lValue = $row[sale_qty]; $strSelect2 = "SELECT * FROM stock WHERE P_ID = '$P_ID'"; $reSelect2 = mysql_query($strSelect2); if($reSelect2){ $readerSelect2=mysql_fetch_array($reSelect2); $reTotle2 = $readerSelect2[qty]-$lValue; $id_stock2 = $readerSelect2[id_stock2]; $strUpdate2 = "UPDATE stock set qty='$reTotle2' WHERE id_stock2 = '$id_stock2'"; //$strUpdate2 = "UPDATE stock2 set qty='$reTotle2',qty_order='$reTotalOrder2' WHERE id_stock2 = '$id_stock2'"; $reUpdate2 = mysql_query($strUpdate2); } //================================================================ } } echo("<script language='javascript'> window.alert('อัพเดทข้อมูลเรียบร้อยแล้วค่ะ'); window.location='purchace_Order.php'; </script>"); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ } ?> <script language="javascript"> //alert("อัพเดทข้อมูลเรียบร้อยแล้วค่ะ") //window.location="Purchace_Order.php"; </script> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง