<?php
include '_connect.php';
 $BILL_NOX = $_GET['BILL_NO'];
 $sql = "SELECT * FROM EHONGDB.dbo.product_turnbill WHERE BILL_NO = '$BILL_NOX'";
 // echo $sql;
 $select=$conn->prepare($sql);
 $select->execute();
 $fetch=$select->fetch();
 $BILL_NO = $fetch['BILL_NO'];
 $BUY_TYPE = $fetch['BUY_TYPE'];
 $BILL_DATE = $fetch['BILL_DATE'];
 $PS_NAME = $fetch['PS_NAME'];
 $SERIAL_NO = $fetch['SERIAL_NO'];
 $PSERIAL_NO = $fetch['PSERIAL_NO'];
 $BRAND_NAME = $fetch['BRAND_NAME'];
 $SUM_TOTAL = $fetch['SUM_TOTAL'];
 $SUM_MONEY1 = $fetch['SUM_MONEY1'];
 $SUM_MONEY2 = $fetch['SUM_MONEY2'];
 $STATUS = $fetch['STATUS'];
 $BILL_ADATE = date('Y-m-d');

 $sql_ib64 = "INSERT INTO CONFIG.dbo.ACT_TURNX
 (BILL_NO, BUY_TYPE, BILL_DATE, PS_NAME, SERIAL_NO, PSERIAL_NO,
 BRAND_NAME, SUM_TOTAL, SUM_MONEY1, SUM_MONEY2, STATUS, FEE_STATUSX,
 FEE_STATUSX1, BILL_ADATE)
 VALUES ('$BILL_NO','$BUY_TYPE','$BILL_DATE','$PS_NAME','$SERIAL_NO','$PSERIAL_NO',
 '$BRAND_NAME','$SUM_TOTAL','$SUM_MONEY1','$SUM_MONEY2','$STATUS','07',
 'รถตีเทิร์น','$BILL_ADATE')";
 // echo $sql_ib64;
 $result = $conn->query($sql_ib64);
 if ($result) {
   echo "yes";
   echo "<script>alert('บันทึกข้อมูลสำเร็จ');window.location='act_index_new3.php';</script>";
 }
 else {
   echo "Error : " . $sql . "<br>" . $conn->error;
   echo "<script>alert('บันทึกข้อมูลไม่สำเร็จ');window.location='act_index_new3.php';</script>";
 }

?>
