7 changed files with 19297 additions and 4855 deletions
Binary file not shown.
File diff suppressed because it is too large
Binary file not shown.
File diff suppressed because it is too large
@ -1,77 +1,66 @@ |
|||
<?php |
|||
$now = gmdate("YmdHis"); |
|||
$data = 'M0000.' . $now; |
|||
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false); |
|||
?> |
|||
require_once('../../T8_Authorization_from_bpm.php'); |
|||
require_once('../connt8.php'); |
|||
|
|||
<script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script> |
|||
<script> |
|||
var body = [{ |
|||
"name": "salIncomeApplyMaster", |
|||
"rows": [{ |
|||
"BillNo": "Z001", |
|||
"BillDate": 20160811, |
|||
"OrgId": "1000", |
|||
"FOrgId": "1000", |
|||
"TypeId": "RR", |
|||
"BpOrgId": "1000", |
|||
"BizPartnerId": "C002", |
|||
"CurrId": "RMB", |
|||
"CurrOAmount": 1, |
|||
"CurrLAmount": 1, |
|||
"PersonId": "T001", |
|||
"DtOrgId": "1000", |
|||
"DueToId": "C002", |
|||
"TaxId": "123", |
|||
"CompId": "1000" |
|||
}] |
|||
}, |
|||
{ |
|||
"name": "salIncomeApplyDetail", |
|||
"rows": [{ |
|||
"BillNo": "Z001", |
|||
"IncomeId": "F203", |
|||
"TaxId": "ST003", |
|||
"RowCode": 1, |
|||
"ItemType": "1", |
|||
"SPrice": 50, |
|||
"SQuantity": 1, |
|||
"FromSourceTag": 0, |
|||
"FromBillNo": "123" |
|||
}] |
|||
} |
|||
$validation = get_Auth(); |
|||
$data = [ |
|||
[ |
|||
"name" => "OtherStockOutMtable", |
|||
"rows" => [ |
|||
[ |
|||
"BillNo" => "00850110", // 單據編號 varchar(20) |
|||
"BillDate" => 20210427, // 單據日期 int |
|||
"OrgId" => "1000", //組織 varchar(20) |
|||
"FOrgId" => "1000", //核算組織 varchar(20) |
|||
"TypeId" => "OS", //單據類型 varchar(10) |
|||
"BizPartnerId" => "", //往來對象(供應商) 可為空 |
|||
"PersonId" => "C0003", // 經辦人員 varchar(20) |
|||
"DeptId" => "250", // 經辦部門 varchar(20) |
|||
"CompId" => "1001" // 公司 varchar(20) |
|||
] |
|||
] |
|||
], [ |
|||
"name" => "OtherStockOutDetail", |
|||
"rows" => [ |
|||
[ |
|||
"BillNo" => "00850110", //單據編號 varchar(20) |
|||
"RowCode" => 1, // 序號 int(10) |
|||
"MaterialId" => "MX00021003", // 產品代碼 -> 產品集成 varchar(40) |
|||
"SupplyOrgId" => "1000", // 供貨組織代碼 varchar(20) |
|||
"SQuantity" => 1, // 交易數量 numeric(19) |
|||
"WarehouseId" => "100" // 倉庫代碼 varchar(20) |
|||
] |
|||
] |
|||
] |
|||
]; |
|||
$api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/STKOTHERSTOCKOUT/PostERPData'; |
|||
$header = [ |
|||
"CHI_Authorization :" . $validation |
|||
]; |
|||
$ch = curl_init(); |
|||
curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL |
|||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); |
|||
curl_setopt($ch, CURLOPT_POST, 1); |
|||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); |
|||
|
|||
var json = JSON.stringify(body); |
|||
console.log(json); |
|||
// 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); |
|||
// // } |
|||
// }) |
|||
$.ajax({ |
|||
url: 'https://127.0.0.1:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData', |
|||
method: 'POST', |
|||
dataType: 'json', |
|||
// headers: headerParam, |
|||
data: body, |
|||
success: function(res) { |
|||
console.log('Success'); |
|||
}, |
|||
error: function(err) { |
|||
console.log(err); |
|||
} |
|||
}) |
|||
</script> |
|||
$response = curl_exec($ch); |
|||
if ($response === false) { |
|||
echo 'Curl error: ' . curl_error($ch); |
|||
} else { |
|||
$result = json_decode($response, true); |
|||
if ($result['Status'] == 'Error') { |
|||
echo '<pre>'; |
|||
print_r($result); |
|||
echo '</pre>'; |
|||
echo 'API 傳入錯誤,' . $result['ErrorMsg']; |
|||
} else { |
|||
echo '<pre>'; |
|||
print_r($result['Status']); |
|||
echo '</pre>'; |
|||
return $result; |
|||
} |
|||
} |
|||
|
|||
curl_close($ch); |
|||
|
Loading…
Reference in new issue