diff --git a/wms/purchase-api.php b/wms/purchase-api.php
deleted file mode 100644
index c3259ef6..00000000
--- a/wms/purchase-api.php
+++ /dev/null
@@ -1,49 +0,0 @@
- prepare($sql_purchaseApply);
- $query_purchaseApply -> execute();
- $result = $query_purchaseApply -> fetchAll();
- return $result;
-}
-
-
-
-
-// print_r(get_purchase_apply($validation,$GroupId,"S230300001-14"));
-//費用申請單API 不能用
-function get_purchase_apply($validation,$GroupId,$BillNo){
- $apiurl = "http://60.244.87.101:880//twWebAPI/V1/PURFEEAPPLY/GetERPData?pkValue=$BillNo";
- // echo $apiurl . "\n";
- $headerParam = [
- 'CHI_Authorization: ' . $validation,
- 'GroupId:'.$GroupId
- ];
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $apiurl);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headerParam);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
-
- $response = curl_exec($ch);
- if ($response === false) {
- echo 'Curl error: ' . curl_error($ch);
- } else {
- $result = json_decode($response, true);
- print_r($result);
- }
-
- curl_close($ch);
-}
\ No newline at end of file
diff --git a/wms/purchase-apply-create.php b/wms/purchase-apply-create.php
new file mode 100644
index 00000000..dac47245
--- /dev/null
+++ b/wms/purchase-apply-create.php
@@ -0,0 +1,2 @@
+ 0) {
+ $column_str = "('$user_id'" . ",'";
+ $column_str .= implode("','", $follower);
+ $column_str .= "')";
+ $add_sql .= " OR main.PersonId IN $column_str)";
+ } else {
+ $add_sql .= ")";
+ };
+}
+if (!is_null($start_date)) {
+ $start_date = (int)date('Ymd', strtotime($start_date));
+ $add_sql .= " AND main.BillDate >= $start_date ";
+}
+if (!is_null($end_date)) {
+ $end_date = (int)date('Ymd', strtotime($end_date));
+ $add_sql .= " AND main.BillDate <= $end_date ";
}
+$main = get_purchaseApply_index($conn, $add_sql);
+// print_r($main);
+
+?>
+
+
採購費用申請單 (對廠商付款)
+
+
+
+
+
+
+
+
+
+
+
+ 單號 |
+ 申請日期 |
+
+ 申請部門 |
+
+ 申請人 |
+ 幣別 |
+ 含稅金額 |
+
+
+
+
+
+ 無資料 |
+
+
+
+
+ |
+ |
+
+ |
+
+ |
+ |
+ |
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wms/purchase-function.php b/wms/purchase-function.php
new file mode 100644
index 00000000..bef96231
--- /dev/null
+++ b/wms/purchase-function.php
@@ -0,0 +1,180 @@
+prepare($sql_purchaseApply);
+ $query_purchaseApply->execute();
+ $result = $query_purchaseApply->fetchAll();
+ return $result;
+ } catch (PDOException $ex) {
+ trigger_error($ex->getMessage(), E_USER_WARNING);
+ return array();
+ }
+}
+
+
+
+
+//費用申請單API 不能用
+function get_purchase_apply($validation, $GroupId, $BillNo)
+{
+ if (is_null($validation) || is_null($GroupId) || is_null($BillNo)) {
+ return "參數錯誤";
+ }
+ $apiurl = "http://60.244.87.101:880//twWebAPI/V1/PURFEEAPPLY/GetERPData?pkValue=$BillNo";
+ $headerParam = [
+ 'CHI_Authorization: ' . $validation,
+ 'GroupId:' . $GroupId
+ ];
+ $ch = curl_init();
+ if (!$ch) {
+ throw new Exception("Could not init cURL");
+ }
+ curl_setopt($ch, CURLOPT_URL, $apiurl);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headerParam);
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
+
+ $response = curl_exec($ch);
+ if ($response === false) {
+ $error = curl_error($ch);
+ curl_close($ch);
+ if (is_null($error)) {
+ throw new Exception("Curl error: Unknown error");
+ } else {
+ throw new Exception("Curl error: " . $error);
+ }
+ }
+
+ $result = json_decode($response, true);
+ if (is_null($result)) {
+ throw new Exception("Failed to decode JSON data");
+ }
+ curl_close($ch);
+ return $result;
+}
+
+function transanction_purchase_apply($validation, $GroupId, $BillNo)
+{
+ date_default_timezone_set("Asia/Taipei");
+ $host = getenv('DB_HOST');
+ $dbuser = getenv('DB_USERNAME');
+ $dbpassword = getenv('DB_PASSWORD');
+ $dbname = getenv('DB_DATABASE');
+ $sqlsrv = getenv('sqlsrv');
+ $Database = getenv('Database');
+ $Account = getenv('Account');
+ $Password = getenv('Password');
+
+ try {
+ $mysqlConn = new PDO("mysql:host=$host;dbname=$dbname", $dbuser, $dbpassword);
+ $mysqlConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+ $mssqlConn = new PDO("sqlsrv:Server=$sqlsrv;Database=$Database", $Account, $Password);
+ $mssqlConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+ $mysqlConn->beginTransaction();
+ $mssqlConn->beginTransaction();
+
+ // 在MySQL数据库中执行插入操作
+ $mysqlInsertQuery = "INSERT INTO your_mysql_table (column1, column2) VALUES (:value1, :value2)";
+ $mysqlStatement = $mysqlConn->prepare($mysqlInsertQuery);
+ $mysqlStatement->execute(array(':value1' => 'value1', ':value2' => 'value2'));
+
+ // 在MSSQL数据库中执行插入操作
+ $mssqlInsertQuery = "INSERT INTO your_mssql_table (column1, column2) VALUES (?, ?)";
+ $mssqlStatement = $mssqlConn->prepare($mssqlInsertQuery);
+ $mssqlStatement->execute(array('value1', 'value2'));
+
+ // 提交事务
+ $mysqlConn->commit();
+ $mssqlConn->commit();
+
+ echo "Transaction successfully committed.";
+ } catch (PDOException $e) {
+ // 如果有异常发生,则回滚事务
+ $mysqlConn->rollBack();
+ $mssqlConn->rollBack();
+ echo "Transaction failed: " . $e->getMessage();
+ }
+}