Cheng 1 year ago
parent
commit
e2ab9be3a7
  1. 965
      wms/account-receivable-renovate-index.php
  2. 69
      wms/contract/testT8API.php
  3. 7
      wms/rib02-create.php
  4. 31
      wms/rib02-submit.php

965
wms/account-receivable-renovate-index.php

File diff suppressed because it is too large

69
wms/contract/testT8API.php

@ -0,0 +1,69 @@
<?php
require_once('../T8_Authorization_from_bpm.php');
// require_once('../connt8.php');
// 其他出庫申請單
$validation = get_Auth();
$data = [
[
"name" => "OtherStockOutMtable",
"rows" => [
[
"BillNo" => "TEST01", // 單據編號 varchar(20)
"BillDate" =>20240120, // 單據日期 int
"OrgId" => "1000", //組織 varchar(20)
"FOrgId" => "1000", //核算組織 varchar(20)
"TypeId" => "OS", //單據類型 varchar(10)
"BizPartnerId" => "03051501", //往來對象(供應商) 可為空
"PersonId" => "C0003", // 經辦人員 varchar(20)
"DeptId" => "250", // 經辦部門 varchar(20)
"CompId" => "1001" // 公司 varchar(20)
]
]
], [
"name" => "OtherStockOutDetail",
"rows" => [
[
"BillNo" => "TEST01", //單據編號 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));
$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);

7
wms/rib02-create.php

@ -120,11 +120,12 @@ foreach ($BizPartner as $biz) {
$invoiceNo = mysqli_query($link, $sql_invoiceNo);
$invoiceNo_array = array();
foreach ($invoiceNo as $invoice) {
array_push($invoiceNo_array, $invoice['InvoiceNo']);
if(is_iterable($invoiceNo)){
foreach ($invoiceNo as $invoice) {
array_push($invoiceNo_array, $invoice['InvoiceNo']);
}
}
$BizJSON = json_encode($BusinessPartner);
$InvoiceJSON = json_encode($invoiceNo_array);
$sql_Project = "SELECT * FROM comProject";

31
wms/rib02-submit.php

@ -19,10 +19,20 @@ foreach ($BizPartner as $biz) {
$sql_invoiceNo = "SELECT DISTINCT InvoiceNo FROM rib_sub WHERE rib_id !== $rib_id";
$invoiceNo = mysqli_query($link, $sql_invoiceNo);
$invoiceNo_array = array();
foreach ($invoiceNo as $invoice) {
array_push($invoiceNo_array, $invoice['InvoiceNo']);
if (is_iterable($invoiceNo)) {
foreach ($invoiceNo as $invoice) {
array_push($invoiceNo_array, $invoice['InvoiceNo']);
}
}
// 取得同筆報銷單的明細資料
$sql_all_ribsub = "SELECT * FROM rib_sub WHERE rib_id = $rib_id";
$all_ribsub_data = mysqli_query($link, $sql_all_ribsub);
if (is_iterable($all_ribsub_data)) {
foreach ($all_ribsub_data as $allribsub) {
$CurrLAmount = $allribsub['CurrentLAmount'];
}
}
$RowCode = $_POST['RowCode'];
$FeeDate = $_POST['FeeDate'];
$FeeTypeGen = isset($_POST['FeeTypeGen']) ? $_POST['FeeTypeGen'] : null;
@ -42,9 +52,10 @@ $IsCounteract = $_POST['IsCounteract'];
$InvoiceId = $_POST['InvoiceId'];
$VoucherCount = empty($_POST['VoucherCount']) ? 1 : $_POST['VoucherCount'];
$VoucherType = isset($_POST['VoucherType']) ? $_POST['VoucherType'] : 0;
$InvoiceNo = empty($_POST['InvoiceNo']) ? " ": (in_array(str_replace("-", "",$_POST['InvoiceNo']), $invoiceNo_array) ? " ": str_replace("-", "",$_POST['InvoiceNo']));
$InvoiceNo = empty($_POST['InvoiceNo']) ? " " : (in_array(str_replace("-", "", $_POST['InvoiceNo']), $invoiceNo_array) ? " " : str_replace("-", "", $_POST['InvoiceNo']));
$CurrLAmount = empty($_POST['CurrLAmount']) ? ($CurrId == "TWD" ? 1 : null) : $_POST['CurrLAmount'];
$CurrLAmount = empty($_POST['CurrLAmount']) ? null : $_POST['CurrLAmount'];
// $comSupplierName = empty($_POST['comSupplierName']) ? null : $_POST['comSupplierName'];
$FromSourceTag = 0;
$TaxRate = ($TaxId == "ST005") ? 0.05 : 0;
@ -54,7 +65,7 @@ if ($CurrId == "TWD") {
$OAmountUnWithTax = isset($_POST['OAmountUnWithTax']) ? round($_POST['OAmountUnWithTax']) : null;
$LAmountUnWithTax = isset($_POST['LAmountUnWithTax']) ? round($_POST['LAmountUnWithTax']) : null;
$LAmount = isset($_POST['LAmount']) ? round($_POST['LAmount']) : null;
}else{
} else {
$OTax = isset($_POST['OTax']) ? round($_POST['OTax'], 2) : NULL;
$LTax = isset($_POST['LTax']) ? round($_POST['LTax'], 2) : NULL;
$OAmountUnWithTax = isset($_POST['OAmountUnWithTax']) ? round($_POST['OAmountUnWithTax'], 2) : null;
@ -62,7 +73,7 @@ if ($CurrId == "TWD") {
$LAmount = isset($_POST['LAmount']) ? round($_POST['LAmount'], 2) : null;
}
$TaxNo = empty($_POST['TaxNo']) ? '' : $_POST['TaxNo'];
$TaxNo = empty($_POST['TaxNo']) ? ' ' : $_POST['TaxNo'];
if (empty($TaxNo)) {
$comSupplierName = "雜項請款用";
} else {
@ -90,10 +101,13 @@ if (isset($comSupplierName) && ($comSupplierName != "雜項請款用")) {
$SQL1 = "";
if ($submit == "add") {
if (($user_id == "M0056") || ($user_id == "M0209")) {
$ribsub_query = "SELECT * FROM rib_sub WHERE rib_id = $rib_id";
$ribsub_data = mysqli_query($link, $ribsub_query);
$SQL1 = "INSERT INTO rib_sub (`RowCode`,`rib_id`,`RowNo`,`FeeDate`,`FeeTypeId`,`WriteOffType`,
`BizOrgId`,`WriteOffId`,`FeeOrgId`,`FeeDeptId`,`FeeCompanyId`,`UnitId`,`Quantity`,
`Price`,`OAmount`,`FeeNoteShow`,`CurrId`,`SupplyOrgId`,`CurrOAmount`,`FromSourceTag`,`TaxId`,`IsCounteract`,`InvoiceId`,`TaxRate`,`CreatorId`,`TaxNo`,`CurrentLAmount`,`OTax`,`LTax`,
`Price`,`OAmount`,`FeeNoteShow`,`CurrId`,`SupplyOrgId`,`CurrOAmount`,`FromSourceTag`,`TaxId`,`IsCounteract`,`InvoiceId`,`TaxRate`,`CreatorId`,`TaxNo`,`OTax`,`LTax`,
`OAmountUnWithTax`,`LAmountUnWithTax`,`LAmount`";
$SQL1 .= isset($CurrLAmount) ? ",`CurrentLAmount`" : "";
$SQL1 .= empty($ProjectId) ? "" : ",`ProjectId`";
$SQL1 .= isset($FeeTypeGen) ? ",`FeeTypeGen`" : "";
$SQL1 .= empty($CU_MaterialId) ? "" : ",`CU_MaterialId`";
@ -105,8 +119,9 @@ if ($submit == "add") {
$SQL2 = ") VALUES ($RowCode, $rib_id, $RowCode,$FeeDate,'$FeeTypeId',2,
'1000','$WriteOffId','1000','$FeeDeptId','1000','$UnitId',$Quantity,
$Price,$OAmount,'$FeeNoteShow','$CurrId','1000',1,0,'$TaxId',$IsCounteract,'$InvoiceId',$TaxRate,'$user_id','$TaxNo',$CurrLAmount,$OTax,$LTax,
$Price,$OAmount,'$FeeNoteShow','$CurrId','1000',1,0,'$TaxId',$IsCounteract,'$InvoiceId',$TaxRate,'$user_id','$TaxNo',$OTax,$LTax,
$OAmountUnWithTax,$LAmountUnWithTax,$LAmount";
$SQL2 .= isset($CurrLAmount) ? "," . $CurrLAmount : "";
$SQL2 .= empty($ProjectId) ? "" : ",'" . $ProjectId . "'";
$SQL2 .= isset($FeeTypeGen) ? "," . $FeeTypeGen : "";
$SQL2 .= empty($CU_MaterialId) ? "" : ",'" . $CU_MaterialId . "'";

Loading…
Cancel
Save