19 changed files with 968 additions and 1051 deletions
Binary file not shown.
@ -1,30 +0,0 @@ |
|||||
<?php |
|
||||
$envFile = __DIR__ . '/../.env'; // .env 文件的路徑 |
|
||||
|
|
||||
if (file_exists($envFile)) { |
|
||||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
||||
if ($lines !== false) { |
|
||||
foreach ($lines as $line) { |
|
||||
list($key, $value) = explode('=', $line, 2); |
|
||||
$key = trim($key); |
|
||||
$value = trim($value); |
|
||||
// 设置环境变量 |
|
||||
putenv("$key=$value"); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
date_default_timezone_set("Asia/Taipei"); |
|
||||
$host = getenv('DB_HOST'); |
|
||||
$dbuser = getenv('DB_USERNAME'); |
|
||||
$dbpassword = getenv('DB_PASSWORD'); |
|
||||
$dbname = getenv('DB_DATABASE'); |
|
||||
$link = mysqli_connect($host,$dbuser,$dbpassword,$dbname); |
|
||||
if($link){ |
|
||||
mysqli_query($link,'SET NAMES utf8'); |
|
||||
// echo "正確連接資料庫"; |
|
||||
} |
|
||||
else { |
|
||||
echo "不正確連接資料庫</br>" . mysqli_connect_error(); |
|
||||
} |
|
||||
|
|
||||
?> |
|
@ -0,0 +1,90 @@ |
|||||
|
<?php |
||||
|
include "T8_Authorization.php"; |
||||
|
echo "ii"; |
||||
|
?> |
||||
|
<script> |
||||
|
get_Auth(); |
||||
|
window.addEventListener('message', function(event) { |
||||
|
if (event.origin === "http://localhost:3000" && (typeof event.data === "string")) { |
||||
|
var validation = event.data; |
||||
|
console.log("event"); |
||||
|
console.log(validation); |
||||
|
|
||||
|
// var corsurl = 'http://cors-anywhere.herokuapp.com/'; |
||||
|
var apiurl = 'http://60.244.87.101:880/twWebAPI/V1/APCHECKBILL/PostERPData'; |
||||
|
headerParam = { |
||||
|
CHI_Authorization: `${validation}`, |
||||
|
}; |
||||
|
var body = [{ |
||||
|
"name": "MasterTable", |
||||
|
"rows": [{ |
||||
|
"BillNo": "Z001", |
||||
|
"BillDate": 20230930, |
||||
|
"OrgId": "1000", |
||||
|
"TypeId": "OPV", |
||||
|
"BizPartnerId": "03051501", |
||||
|
"CurrId": "RMB", |
||||
|
"CurrLAmount":5, |
||||
|
"TaxId": "ST005", |
||||
|
"PersonId": "M0012", |
||||
|
"DeptId": "220", |
||||
|
"CompId": "1001", |
||||
|
"CreditAgeDate": 20230930, |
||||
|
"RecBizPartnerId": "03051501", |
||||
|
|
||||
|
}] |
||||
|
}, |
||||
|
{ |
||||
|
"name": "DetailTable", |
||||
|
"rows": [{ |
||||
|
"BillNo": "Z001", |
||||
|
"RowCode": 1, |
||||
|
"RowNo": 1, |
||||
|
"ItemType": 0, |
||||
|
"MaterialId": "MX00000001", |
||||
|
"UnitId": "PCS", |
||||
|
"MaterialSpec": "", |
||||
|
"SQuantity": 10, |
||||
|
"SPrice": 141.18, |
||||
|
"OAmount": 1344.57, |
||||
|
"OTax": 67.23, |
||||
|
"OAmountWithTax": 1411.8, |
||||
|
"TaxId": "ST005" |
||||
|
}, |
||||
|
{ |
||||
|
"BillNo": "Z001", |
||||
|
"RowCode": 2, |
||||
|
"RowNo": 2, |
||||
|
"ItemType": 0, |
||||
|
"MaterialId": "MX00000001", |
||||
|
"UnitId": "PCS", |
||||
|
"MaterialSpec": "", |
||||
|
"SQuantity": 15, |
||||
|
"SPrice": 141.18, |
||||
|
"OAmount": 2016.86, |
||||
|
"OTax": 100.84, |
||||
|
"OAmountWithTax": 2117.7, |
||||
|
"TaxId": "ST005" |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
]; |
||||
|
var json = JSON.stringify(body); |
||||
|
obj = { |
||||
|
type: 'POST', |
||||
|
// url: `${corsurl}${apiurl}`, |
||||
|
url: `${apiurl}`, |
||||
|
// dataType: 'json', |
||||
|
headers: headerParam, |
||||
|
data: json, |
||||
|
dataType: "json", |
||||
|
success: function(res) { |
||||
|
console.log(res.Status); |
||||
|
console.log(res.ErrorMsg); |
||||
|
console.log(res.Data); |
||||
|
} |
||||
|
}; |
||||
|
jQuery.ajax(obj); |
||||
|
} |
||||
|
}) |
||||
|
</script> |
@ -0,0 +1,35 @@ |
|||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> |
||||
|
<?php |
||||
|
$now = gmdate("YmdHis"); |
||||
|
$data = 'M0000.' . $now; |
||||
|
$sign = hash_hmac('SHA256', $data, '964C834F7BF2BB70', false); |
||||
|
|
||||
|
?> |
||||
|
|
||||
|
<script> |
||||
|
function get_Auth() { |
||||
|
var api_key = '964C834F7BF2BB70'; |
||||
|
var validation = ""; |
||||
|
// var corsurl = 'http://cors-anywhere.herokuapp.com/'; |
||||
|
var apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; |
||||
|
headerParam = { |
||||
|
UserId: 'M0000', |
||||
|
Pwd: 'M012290493119', |
||||
|
TimestampUTC: <?= $now ?>, |
||||
|
Sign: '<?= $sign ?>' |
||||
|
}; |
||||
|
obj = { |
||||
|
type: 'get', |
||||
|
// url: `${corsurl}${apiurl}`, |
||||
|
url: `${apiurl}`, |
||||
|
dataType: 'json', |
||||
|
headers: headerParam, |
||||
|
success: function(res) { |
||||
|
validation = res.Data['CHI_Authorization']; |
||||
|
window.parent.postMessage(validation,'http://localhost:3000'); |
||||
|
// window.parent.postMessage(validation,'https://masada.com.tw'); |
||||
|
} |
||||
|
}; |
||||
|
jQuery.ajax(obj); |
||||
|
} |
||||
|
</script> |
Loading…
Reference in new issue