11 changed files with 890 additions and 711 deletions
@ -0,0 +1,36 @@ |
|||
<?php |
|||
require_once("../../T8_Authorization_from_bpm.php"); |
|||
|
|||
function T8API($data) |
|||
{ |
|||
echo '<pre>'; |
|||
print_r(json_encode($data)); |
|||
echo '</pre>'; |
|||
|
|||
$api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; |
|||
$validation = get_Auth(); |
|||
$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_POST, 1); |
|||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); |
|||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); |
|||
$response = curl_exec($ch); |
|||
if ($response === false) { |
|||
echo 'Curl error: ' . curl_error($ch); |
|||
} else { |
|||
$result = json_decode($response, true); |
|||
// $validation = $result['Data']['CHI_Authorization']; |
|||
echo '<pre>'; |
|||
print_r($result); |
|||
echo '</pre>'; |
|||
return $result; |
|||
} |
|||
|
|||
curl_close($ch); |
|||
} |
|||
// T8API($data); |
@ -0,0 +1,115 @@ |
|||
[ |
|||
{ |
|||
"name": "salIncomeApplyMaster", |
|||
"rows": [ |
|||
{ |
|||
"BillNo": "B23100060", |
|||
"BillDate": "2024-01-5215-52", |
|||
"OrgId": "1000", |
|||
"FOrgId": "1000", |
|||
"TypeId": "RAS", |
|||
"BpOrgId": "1000", |
|||
"BizPartnerId": "B23100060", |
|||
"CurrId": "TWD", |
|||
"CurrOAmount": 1, |
|||
"CurrLAmount": 1, |
|||
"PersonId": "M0065", |
|||
"DtOrgId": "1000", |
|||
"DueToId": "B23100060", |
|||
"TaxId": "ST005", |
|||
"CompId": "1001", |
|||
"CreatorId": "M0225" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"name": "salIncomeApplyDetail", |
|||
"rows": [ |
|||
{ |
|||
"BillNo": " B23100060 ", |
|||
"IncomeId": " A40007 ", |
|||
"TaxId": "ST005", |
|||
"RowCode": 1, |
|||
"RowNo": 1, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 3, |
|||
"ProjectId": " B23100060 ", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": " 4TZ53201 " |
|||
}, |
|||
{ |
|||
"BillNo": " B23100060 ", |
|||
"IncomeId": " A40007 ", |
|||
"TaxId": "ST005", |
|||
"RowCode": 2, |
|||
"RowNo": 2, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 3, |
|||
"ProjectId": " B23100060 ", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": " 4TZ53201 " |
|||
}, |
|||
{ |
|||
"BillNo": " B23100060 ", |
|||
"IncomeId": " A40007 ", |
|||
"TaxId": "ST005", |
|||
"RowCode": 3, |
|||
"RowNo": 3, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 3, |
|||
"ProjectId": " B23100060 ", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": " 4TZ53201 " |
|||
}, |
|||
{ |
|||
"BillNo": " B23100060 ", |
|||
"IncomeId": " A40007 ", |
|||
"TaxId": "ST005", |
|||
"RowCode": 4, |
|||
"RowNo": 4, |
|||
"ItemType": 1, |
|||
"SPrice": 1250, |
|||
"SQuantity": 3, |
|||
"ProjectId": " B23100060 ", |
|||
"FromSourceTag": 0, |
|||
"CU_MaterialId": " 4TZ53201 " |
|||
} |
|||
] |
|||
} |
|||
] |
|||
|
|||
|
|||
[ |
|||
{ |
|||
"name": "OtherStockOutMtable", |
|||
"rows": [ |
|||
{ |
|||
"BillNo": "Z001", |
|||
"BillDate": 20210427, |
|||
"OrgId": "1000", |
|||
"FOrgId": "1000", |
|||
"TypeId": "OD", |
|||
"BizPartnerId": "Z001", |
|||
"PersonId": "Z001", |
|||
"DeptId": "T001", |
|||
"CompId": "1000" |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"name": "OtherStockOutDetail", |
|||
"rows": [ |
|||
{ |
|||
"BillNo": "Z001", |
|||
"RowCode": 1, |
|||
"MaterialId": "Z001", |
|||
"SupplyOrgId": "1000", |
|||
"SQuantity": 1, |
|||
"WarehouseId": "10" |
|||
} |
|||
] |
|||
} |
|||
] |
@ -1,108 +1,61 @@ |
|||
<?php |
|||
$now = gmdate("YmdHis"); |
|||
$data = 'M0000.' . $now; |
|||
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false); |
|||
|
|||
$test = [ |
|||
"A40005" => 2, |
|||
"A40001" => 3, |
|||
"A40002" => 4, |
|||
require_once('../../T8_Authorization_from_bpm.php'); |
|||
$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) |
|||
] |
|||
] |
|||
] |
|||
]; |
|||
echo '<pre>'; |
|||
print_r($test['A40001']); |
|||
echo '</pre>'; |
|||
$payType = 'A0005'; |
|||
?> |
|||
|
|||
<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" |
|||
// }] |
|||
// } |
|||
// ] |
|||
|
|||
// 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); |
|||
// } |
|||
// }) |
|||
let No = 'B123'; |
|||
let arr = []; |
|||
for (let i = 1; i < 5; i++) { |
|||
let obj = { |
|||
'No': No, |
|||
'name': '12344', |
|||
'mum': i |
|||
}; |
|||
// let arr = []; |
|||
arr.push(obj); |
|||
} |
|||
console.log(JSON.stringify(arr)); |
|||
|
|||
let obj = { |
|||
'A0004': 3, |
|||
'A0005': 4 |
|||
} |
|||
// $data = file_get_contents('test.json'); |
|||
// echo '<pre>'; |
|||
// print_r($data); |
|||
// echo '</pre>'; |
|||
$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_POST, 1); |
|||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); |
|||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); |
|||
$response = curl_exec($ch); |
|||
if ($response === false) { |
|||
echo 'Curl error: ' . curl_error($ch); |
|||
} else { |
|||
$result = json_decode($response, true); |
|||
// $validation = $result['Data']['CHI_Authorization']; |
|||
echo '<pre>'; |
|||
print_r($result); |
|||
echo '</pre>'; |
|||
return $result; |
|||
} |
|||
|
|||
for (let i = 1; i <= obj.<?= $payType ?>; i++) { |
|||
console.log(i); |
|||
} |
|||
</script> |
|||
curl_close($ch); |
|||
|
Loading…
Reference in new issue