diff --git a/wms/contract/api/T8salIncomeApply.php b/wms/contract/api/T8api.php similarity index 84% rename from wms/contract/api/T8salIncomeApply.php rename to wms/contract/api/T8api.php index f419d4d8..7bf12c6f 100644 --- a/wms/contract/api/T8salIncomeApply.php +++ b/wms/contract/api/T8api.php @@ -1,14 +1,14 @@ '; - print_r(json_encode($data)); - echo ''; + // echo '
'; + // print_r(json_encode($data)); + // echo ''; $header = [ "CHI_Authorization :" . $validation, "GroupId:TEST" @@ -19,7 +19,7 @@ function T8API($data) curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_POST, 1); // 使用 POST - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE)); $response = curl_exec($ch); if ($response === false) { diff --git a/wms/contract/api/getContractData.php b/wms/contract/api/getContractData.php index 7ff973d6..667c33b7 100644 --- a/wms/contract/api/getContractData.php +++ b/wms/contract/api/getContractData.php @@ -74,12 +74,59 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont $elevators_results = $stmt->fetchAll(PDO::FETCH_ASSOC); $elevators_detail_arr = []; $contract_elevator_qty = 0; - // $sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='B' "; - // $stmt = $conn->prepare($sql); - // $stmt->bindParam(':mid', $mid); - // $stmt->execute(); - // $option_results = $stmt->fetchAll(PDO::FETCH_ASSOC); - // $option_arr = []; + $sql = "SELECT * FROM pricereview_pay WHERE mid = :mid"; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':mid', $mid); + $stmt->execute(); + + $pay_amount = $stmt->fetchAll(PDO::FETCH_ASSOC); + $pay_arr = [ + 'equipment_total' => 0, //設備款 + 'install_total' => 0, //安裝款 + 'elevotor_pay_detail' => [] + ]; + $elevotor_pay_detail = []; + foreach ($pay_amount as $i => $pay) { + if ($pay['pay_kind'] <= 4) { + // 設備款總價 + $pay_arr['equipment_total'] += $pay['pay_amount']; + if ($pay['pay_scale'] > 0) { + $elevotor_pay_detail = [ + 'kind' => $pay['pay_kind'], + 'pay_scale' => $pay['pay_scale'], + 'pay_period' => $pay['pay_period'], + 'amount' => $pay['pay_amount'] + ]; + // $elevotor_pay_detail['pay_scale'] = $pay['pay_scale']; + // $pay_arr['elevotor_pay_detail']['kind'] = $pay['pay_kind']; + // $pay_arr['elevotor_pay_detail']['pay_scale'] = $pay['pay_scale']; + // $pay_arr['elevotor_pay_detail']['pay_period'] = $pay['pay_period']; + // $pay_arr['elevotor_pay_detail']['amount'] = $pay['pay_amount']; + array_push($pay_arr['elevotor_pay_detail'], $elevotor_pay_detail); + } + } else { + $pay_arr['install_total'] += $pay['pay_amount']; + if ($pay['pay_scale'] > 0) { + $a = $pay['pay_kind']; + $elevotor_pay_detail = [ + 'kind' => "$a", + 'pay_scale' => $pay['pay_scale'], + 'pay_period' => $pay['pay_period'], + 'amount' => $pay['pay_amount'] + ]; + array_push($pay_arr['elevotor_pay_detail'], $elevotor_pay_detail); + + // $elevotor_pay_detail[] = $pay['pay_kind']; + // $pay_arr['elevotor_pay_detail']['kind'] = $pay['pay_kind']; + // $pay_arr['elevotor_pay_detail']['pay_scale'] = $pay['pay_scale']; + // $pay_arr['elevotor_pay_detail']['pay_period'] = $pay['pay_period']; + // $pay_arr['elevotor_pay_detail']['amount'] = $pay['pay_amount']; + } + } + } + // echo "
"; + // print_r($pay_arr); + // echo ""; foreach ($elevators_results as $keys) { $contract_elevator_qty += $keys['item_qty']; @@ -152,7 +199,7 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont // echo ""; } else { $result['option_other_price'] += $option['item_unit_price'] * intval($option['item_qty']); - // echo '3..'; + // echo ' } // echo '
'; // print_r($option['item_no'] . '--->' . $option['item_unit_price'] . '--->' . $option['item_qty']); @@ -178,12 +225,11 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont array_push($elevators_detail_arr, $result); } } - // print_r(COUNT($option_results)); $count = COUNT($elevators_detail_arr); - $contract['elevators'] = $elevators_results; $contract['elevators_detail_arr'] = $elevators_detail_arr; + $contract['pay_arr'] = $pay_arr; $contract['nums'] = $count; $contractResponse = json_encode($contract); @@ -191,7 +237,7 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont header('Content-Type: application/json'); // 將 JSON 回應返回給客戶端 - // echo $contractResponse; + echo $contractResponse; } catch (PDOException $e) { die("ERROR!!!: " . $e->getMessage()); } diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index 445d0b5b..6b9b210b 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -100,7 +100,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c echo json_encode($fail_arr); exit(); } - // T8insert($_POST, $facilityno, $depId); + T8insert($_POST, $facilityno, $depId); /// 獎金計算 $aaa = bonusCreate($_POST, $facilityno, $conn); if ($aaa['status'] == 2) { @@ -108,7 +108,6 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c echo $aaa['data']; exit(); } - exit; //create account table $accounttype = "A"; $accountid = $vat; @@ -120,8 +119,6 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $create_at = date('Y-m-d H:i:s'); $conn->beginTransaction(); - // bonusCreate($_POST, $facilityno, $conn); - // exit(); $sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)"; $stmt = $conn->prepare($sql_str); @@ -135,7 +132,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(':repairerid', $repairerid); $stmt->bindParam(':creater', $creater); $stmt->bindParam(':create_at', $create_at); - // $stmt->execute(); + $stmt->execute(); //create contract table @@ -171,7 +168,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(':end_date', $end_date); $stmt->bindParam(':creater', $creater); $stmt->bindParam(':create_at', $create_at); - // $stmt->execute(); + $stmt->execute(); //create facility table // $createFacilityNo = new CreateFacilityNo(); @@ -246,7 +243,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(':area', $area); $stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']); $stmt->bindParam(':licensedate', $ADuseful_date); - // $result = $stmt->execute(); + $result = $stmt->execute(); } //create schedule table @@ -267,7 +264,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(':duedate', $combo[1]); $stmt->bindParam(':creater', $creater); $stmt->bindParam(':create_at', $create_at); - // $result = $stmt->execute(); + $result = $stmt->execute(); } } // create contract_b_signed_back table @@ -374,11 +371,11 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->bindParam(":created_by", $user_id); $stmt->bindParam(':payType', $payType); - // $stmt->execute(); + $stmt->execute(); // T8insert($_POST, $facilityno); - // header('Content-Type: application/json'); + header('Content-Type: application/json'); $jsonData = json_encode($files); $conn->commit(); @@ -394,7 +391,7 @@ function T8insert($data, $facilityno, $depId) { require_once("../connt8.php"); // 引入 T8 API 連線 - require_once("./T8salIncomeApply.php"); + require_once("./T8api.php"); $contractno = !empty($data['contractno']) ? $data['contractno'] : null; // 合約號 $address = !empty($data['address']) ? $data['address'] : null; // 客戶地址 @@ -572,23 +569,45 @@ function T8insert($data, $facilityno, $depId) // 分期代碼計算 $IncomeId = [ - 'A40006' => 1, //年繳 - 'A40007' => 4, //季繳 - 'A40003' => 12, //月繳 - 'A40004' => 6, //雙月繳 - 'A40005' => 2 //半年繳 + 'A40006' => 12, //年繳 + 'A40007' => 3, //季繳 + 'A40003' => 1, //月繳 + 'A40004' => 2, //雙月繳 + 'A40005' => 6 //半年繳 ]; - //分幾期 => 總共保養月 / 分期月 - $SQuantity = $elevator['maintain_months'] / $IncomeId[$payType]; + // 幾年 + // $SQuantityYear = $elevator['maintain_months'] / 12; + //分幾期 () => 總共保養月 / 分期月 + $SQuantitya = $elevator['maintain_months'] / $IncomeId[$payType]; + $SQuantity = $IncomeId[$payType]; + // $paymonth = $IncomeId[$payType] * $SQuantity; $date_1 = getNext25thDate($contract_begin_date); - // 依每台電梯去加入各個的付款項 - for ($i = 0; $i < $IncomeId[$payType]; $i++) { + for ($i = 1; $i <= $SQuantitya; $i++) { $row++; // 計算分期款的收款月份 - $paymonth = $i * $SQuantity; + $paymonth = $i * $IncomeId[$payType]; + // switch($IncomeId[$payType]): + // case (1): + // $paymonth = $i * $IncomeId[$payType]; + // $countDay = date('Y-m-d', strtotime("$date_1 + $paymonth years")); + // break; + // case (2): + // $paymonth = $i * $IncomeId[$payType]; + // $countDay = date('Y-m-d', strtotime("$date_1 + $paymonth months")); + // break; + // case (12): + // $countDay = date('Y-m-d', strtotime("$date_1 + $paymonth months")); + // break; + // case (6): + // $countDay = date('Y-m-d', strtotime("$date_1 + $paymonth months")); + // break; + // case (2): + // $countDay = date('Y-m-d', strtotime("$date_1 + $paymonth months")); + // break; + $countDay = date('Y-m-d', strtotime("$date_1 + $paymonth months")); $payDay = str_replace('-', '', $countDay); $rows_data = [ @@ -605,9 +624,6 @@ function T8insert($data, $facilityno, $depId) "CU_EstPayDate" => intval($payDay) ]; $salIncomeApplyDetail_rows[] = $rows_data; - // echo '- - - - \ No newline at end of file +// [ +// { +// //salSalesOrder +// "name": "MainSalesOrder", +// "rows": [ +// { +// "BillNo": "Z001", //合約單號 +// "BillDate": 20210420, //簽約日期 +// "TypeId": "SO", // +// "FOrgId": "1000", +// "OrgId": "1000", +// "ModeId": "T", // T汰改 M新梯 +// "BizPartnerId": "M0225", //創建人ID +// "CurrId": "TWD", +// "CurrOAmount": 1, +// "CurrLAmount": 1, +// "PersonId": "M0225", //業務人員 +// "DueToId": "512", //業務部門 +// "TradeConditionId": "", +// "TaxId": "ST005", +// "CreditorCompId": "1000", +// "CreditorOrgId": "1000", +// "CreditorCurrOAmount": 1, +// "CreditorCurrLAmount": 1, +// "CompId": "1000" +// } +// ] +// }, +// { +// //salSalesOrderDetail +// "name": "SubOrder", +// "rows": [ +// { +// "SupplyCompId": "1001", +// "SupplyOrgId": "1000", +// "TaxId": "ST005", +// "RequirementDate": 20210420, //出貨日期 +// "ConsignmentDate": 20210420, //發貨日期 +// "DispatchCompId": "1001", +// "DispatchOrgId": "1000", +// "BillNo": "Z001", //合約號 +// "RowCode": 1, //全部筆數排列 +// "ItemType": 0, +// "MaterialId": "Z001", //作番號 +// "SUnitId": "SET", +// "SQuantity": 1, //交易數量 +// "SPrice": 1 //交易價格 +// } +// ] +// }, +// { +// "name": "salOrderStagePay", +// "rows": [ +// { +// "BillNo": "", +// "RowCode": "", +// "RowNo": "", +// "PayStage": "ST003", //收款階段 +// "PlanPercentage": "Z001", //計劃收款比例(%) +// "PlanPayAmt": 1, //計劃收款金額 +// "PlanPayDate": 1, //計劃收款日期 1.第一筆都是簽約日 +// "UnWriteOffOAmount": 1 //未核銷金額 +// } +// ] +// } +// ] +require_once("../../T8_Authorization_from_bpm.php"); + +$api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData"; + +$validation = get_Auth(); + +$MainSalesOrder_row = [ + "BillNo" => "M24020076", //合約單號 + "BillDate" => 20210420, //簽約日期 + "TypeId" => "SO", // + "FOrgId" => "1000", + "OrgId" => "1000", + "ModeId" => "M", // T汰改 M新梯 + "BizPartnerId" => "M24020076", //客戶代碼 + "CurrId" => "TWD", + "CurrOAmount" => 1, + "CurrLAmount" => 1, + "PersonId" => "M0225", //業務人員 + "DueToId" => "M24020076", //債務方 + "TradeConditionId" => "", + "TaxId" => "ST005", + "CreditorCompId" => "1001", + "CreditorOrgId" => "1000", + // "CompId" => "1001", + // "CreditorCurrOAmount" => 1, + // "CreditorCurrLAmount" => 1 +]; +// //salSalesOrderDetail +// $SubOrder_row = []; +for ($i = 0; $i < 3; $i++) { + if ($i == 0) { + $row = [ + // "SupplyCompId" => "1001", + // "SupplyOrgId" => "1000", + "TaxId" => "ST005", + "RequirementDate" => 20210420, //出貨日期 + "ConsignmentDate" => 20210420, //發貨日期 + // "DispatchCompId" => "1001", + // "DispatchOrgId" => "1000", + "BillNo" => "M24020076", //合約號 + "RowCode" => $i, //全部筆數排列 + "ItemType" => 1, + "MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) + "SUnitId" => "SET", + "SQuantity" => 1, //交易數量 + "SPrice" => 50000 //交易價格 + ]; + } + if ($i == 1) { + $row = [ + // "SupplyCompId" => "1001", + // "SupplyOrgId" => "1000", + "TaxId" => "ST005", + "RequirementDate" => 20210420, //出貨日期 + "ConsignmentDate" => 20210420, //發貨日期 + // "DispatchCompId" => "1001", + // "DispatchOrgId" => "1000", + "BillNo" => "M24020076", //合約號 + "RowCode" => $i, //全部筆數排列 + "ItemType" => 1, + "MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) + "SUnitId" => "SET", + "SQuantity" => 1, //交易數量 + "SPrice" => 700000 //交易價格 + ]; + } + if ($i == 2) { + $row = [ + // "SupplyCompId" => "1001", + // "SupplyOrgId" => "1000", + "TaxId" => "ST005", + "RequirementDate" => 20210420, //出貨日期 + "ConsignmentDate" => 20210420, //發貨日期 + // "DispatchCompId" => "1001", + // "DispatchOrgId" => "1000", + "BillNo" => "M24020076", //合約號 + "RowCode" => $i, //全部筆數排列 + "ItemType" => 0, + "MaterialId" => "4MH00669", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) + "SUnitId" => "SET", + "SQuantity" => 1, //交易數量 + "SPrice" => 0 //交易價格 + ]; + } + $SubOrder_row[] = $row; +} + +// // $salOrderStagePay_row = []; +// // // for ($i = 0; $i < 2; $i) { +// // // if ($i == 0) { +// // // $row = [ +// // // "BillNo" => "M24010201", +// // // "RowCode" => 1, +// // // "RowNo" => 1, +// // // "PayStage" => "簽約", //收款階段 +// // // "PlanPercentage" => 0.10, //計劃收款比例(%) +// // // "PlanPayAmt" => 100000, //計劃收款金額 +// // // "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 +// // // "UnWriteOffOAmount" => 100000 //未核銷金額 +// // // ]; +// // // } +// // // if ($i == 1) { +// // // $row = [ +// // // "BillNo" => "M24010201", +// // // "RowCode" => 1, +// // // "RowNo" => 1, +// // // "PayStage" => "貨抵工地", //收款階段 +// // // "PlanPercentage" => 0.40, //計劃收款比例(%) +// // // "PlanPayAmt" => 100000, //計劃收款金額 +// // // "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 +// // // "UnWriteOffOAmount" => 100000 //未核銷金額 +// // // ]; +// // // } +// // // if ($i == 2) { +// // // $row = [ +// // // "BillNo" => "M24010201", +// // // "RowCode" => 1, +// // // "RowNo" => 1, +// // // "PayStage" => "試車完工", //收款階段 +// // // "PlanPercentage" => 0.30, //計劃收款比例(%) +// // // "PlanPayAmt" => 100000, //計劃收款金額 +// // // "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 +// // // "UnWriteOffOAmount" => 100000 //未核銷金額 +// // // ]; +// // // } +// // // if ($i == 3) { +// // // $row = [ +// // // "BillNo" => "M24010201", +// // // "RowCode" => 1, +// // // "RowNo" => 1, +// // // "PayStage" => "交車", //收款階段 +// // // "PlanPercentage" => 0.20, //計劃收款比例(%) +// // // "PlanPayAmt" => 100000, //計劃收款金額 +// // // "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 +// // // "UnWriteOffOAmount" => 100000 //未核銷金額 +// // // ]; +// // // } +// // // $salOrderStagePay_row[] = $row; +// // // } +$salOrderStagePay_row = []; +$roww = [ + "PayStage" => "簽約", //收款階段 + "PlanPercentage" => 0.5, //計劃收款比例(%) + "PlanPayAmt" => 375000, //計劃收款金額 + "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 + "BillNo" => "M24020076", + "RowCode" => 1, + "RowNo" => 1, + "UnWriteOffOAmount" => 375000 //未核銷金額 +]; +$roww2 = [ + "PayStage" => "貨抵工地", + "PlanPercentage" => 0.5, + "PlanPayAmt" => 375000, + "PlanPayDate" => 20240101, + "BillNo" => "M24020076", + "RowCode" => 2, + "RowNo" => 2, + "UnWriteOffOAmount" => 375000 +]; +$salOrderStagePay_row[] = $roww; + +$MainSalesOrder = [ + "name" => "MainSalesOrder", + 'rows' => [$MainSalesOrder_row] +]; +$SubOrder = [ + "name" => "SubOrder", + "rows" => $SubOrder_row +]; +$salOrderStagePay = [ + "name" => "salOrderStagePay", + "rows" => $salOrderStagePay_row +]; + +$APIbody = []; +$APIbody[] = $MainSalesOrder; +$APIbody[] = $SubOrder; +$APIbody[] = $salOrderStagePay; +// $data = file_get_contents('test copy.json'); +// $arr = json_decode($data, true); +// echo "'; - // print_r($salIncomeApplyDetail_rows); - // echo ''; } } @@ -652,7 +668,8 @@ function T8insert($data, $facilityno, $depId) // echo ''; // print_r($API_body); // echo ''; - $result = T8API($API_body); + $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; + $result = T8salIncomeApply($API_body, $api_url); if ($result['Status'] == 'Error' || $result['Status'] == 'Fails') { diff --git a/wms/contract/api/postNewContractData.php b/wms/contract/api/postNewContractData.php index c5027877..2a1ebca5 100644 --- a/wms/contract/api/postNewContractData.php +++ b/wms/contract/api/postNewContractData.php @@ -28,29 +28,26 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $elevators = json_decode($_POST['elevators'], true); $elevators_detail_arr = json_decode($_POST['elevators_detail_arr'], true); - // echo ''; - // print_r($elevators); - // echo ''; - // exit; + $files = !empty($_FILES['files']) ? $_FILES['files'] : null; $files_id = null; $fail_arr = []; - if (empty($contractno)) $fail_arr[] = '合約號為必填'; - if (empty($customer)) $fail_arr[] = '客戶名稱為必填'; - if (empty($manager)) $fail_arr[] = '負責人為必填'; - if (empty($vat)) $fail_arr[] = '統編/身分證為必填'; - if (empty($case_name)) $fail_arr[] = '案名為必填'; - if (empty($linkman)) $fail_arr[] = '聯絡人為必填'; - if (empty($lm_tel)) $fail_arr[] = '聯絡人電話為必填'; - if (empty($address)) $fail_arr[] = '地址為必填'; - if (empty($salesman)) $fail_arr[] = '營業員為必填'; - if (empty($qc)) $fail_arr[] = '請選擇QC或官檢'; - if (count($fail_arr) > 0) { - header("HTTP/1.1 422 Unprocessable Entity"); - echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE); - exit(); - } + // if (empty($contractno)) $fail_arr[] = '合約號為必填'; + // if (empty($customer)) $fail_arr[] = '客戶名稱為必填'; + // if (empty($manager)) $fail_arr[] = '負責人為必填'; + // if (empty($vat)) $fail_arr[] = '統編/身分證為必填'; + // if (empty($case_name)) $fail_arr[] = '案名為必填'; + // if (empty($linkman)) $fail_arr[] = '聯絡人為必填'; + // if (empty($lm_tel)) $fail_arr[] = '聯絡人電話為必填'; + // if (empty($address)) $fail_arr[] = '地址為必填'; + // if (empty($salesman)) $fail_arr[] = '營業員為必填'; + // if (empty($qc)) $fail_arr[] = '請選擇QC或官檢'; + // if (count($fail_arr) > 0) { + // header("HTTP/1.1 422 Unprocessable Entity"); + // echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE); + // exit(); + // } //create facility table $createFacilityNo = new CreateFacilityNo(); $dailyNecessities = [ @@ -68,15 +65,19 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $arr[] = $dailyNecessities[$elevator['spec']]; } $facilityno = $createFacilityNo->makeMFacilityNo('M', $arr, intval($elevators_nums)); + echo json_encode($facilityno); - $bonus_result = BounsCount($_POST, $conn, $facilityno); - if (!empty($bonus_result) && $bonus_result['status'] == "2") { - $fail_arr[] = '獎金計算錯誤,請再檢查或連繫資訊人員'; - // header("HTTP/1.1 422 Unprocessable Entity"); - echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE); - exit(); - } - // exit(); + // $bonus_result = BounsCount($_POST, $conn, $facilityno); + // if (!empty($bonus_result) && $bonus_result['status'] == "2") { + // $fail_arr[] = '獎金計算錯誤,請再檢查或連繫資訊人員'; + // // header("HTTP/1.1 422 Unprocessable Entity"); + // echo json_encode($fail_arr, JSON_UNESCAPED_UNICODE); + // exit(); + // } + + T8Insert($_POST, $facilityno, $connT8); + + exit(); $conn->beginTransaction(); $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC"; @@ -171,118 +172,315 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c } } -function T8Insert($data) +function T8Insert($data, $facilityno, $connT8) { - require_once("../connt8.php"); - - $contractno = $data['contractno']; - $partyA = $data['customer']; - $phone = $data['lm_tel']; - $vat = $data['vat']; - $partyAaddress = $data['address']; - $user_id = $data['user_id']; - $salesman = $data['salesman']; - $createAt = date("Y-m-dH-i-s"); - $elevators[] = $data['elevators']; - $createTime = str_replace('-', '', $createAt); - - - $connT8->beginTransaction(); - - $sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId"; - $stmt = $conn->prepare($sql); - $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->execute(); - $result = $stmt->fetch(PDO::FETCH_ASSOC); - // 新增客戶 table - if (empty($result)) { - // 若 客戶資料為空,新增一筆到 comCustomer - // 新增客戶資料 - $sql = "INSERT INTO comBusinessPartner - (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,EMail,CreatorId,CreateTime,BizPartnerTypeId) - VALUES(:BizPartnerId,:BizPartnerName,1,'TW',:WorkTelNo,99999999,:TaxNo,:EnterpriseName,:ContactAddress,:EMail,:CreatorId,:CreateTime,'10')"; + try { + // 引入銷售訂單 API + require_once("./T8API.php"); + + $contractno = $data['contractno']; + $partyA = $data['customer']; + $phone = $data['lm_tel']; + $vat = $data['vat']; + $partyAaddress = $data['address']; + $user_id = $data['user_id']; + $salesman = $data['salesman']; + $createAt = date("Y-m-dH-i-s"); + + + $elevators = !empty($data['elevators_detail_arr']) ? json_decode($data['elevators_detail_arr'], true) : []; //電梯 + $pay_arr = !empty($data['pay_arr']) ? json_decode($data['pay_arr'], true) : []; //電梯 + + $createTime = str_replace('-', '', $createAt); + $signing_date = intval(str_replace("-", '', $data['signing_date'])); //簽訂日期 + // echo + $pay_kind = [ + '1' => '簽約', + '2' => '二次款', + '3' => '貨抵工地', + '4' => '材料其他', + '5' => '試車完工', //安裝完畢 + '6' => '交車' //交車 + ]; + + $sql = "SELECT * FROM comCustomer + WHERE BizPartnerId = :BizPartnerId + "; $stmt = $connT8->prepare($sql); $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->bindParam(':BizPartnerName', $partyA); //客戶名稱 - $stmt->bindParam(':WorkTelNo', $phone); - $stmt->bindParam(':TaxNo', $vat); - // $stmt->bindParam(':EnterpriseName', $customer); //企業名稱 - $stmt->bindParam(':ContactAddress', $partyAaddress); - $stmt->bindParam(':EMail', $email); - $stmt->bindParam(':CreatorId', $user_id); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); - $sql = "INSERT INTO comCustomer + // 新增客戶 table + if (empty($result)) { + // 若 客戶資料為空,新增一筆到 comCustomer + // 新增客戶資料 + $sql = "INSERT INTO comBusinessPartner + (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,CreatorId,CreateTime,BizPartnerTypeId) + VALUES(:BizPartnerId,:BizPartnerName,1,'TW',:WorkTelNo,99999999,:TaxNo,:EnterpriseName,:ContactAddress,:CreatorId,:CreateTime,'10')"; + // $sql = "INSERT INTO comBusinessPartner + // (BizPartnerId,BizPartnerName,BusinessAttr,CountryId,WorkTelNo,BizToDate,TaxNo,EnterpriseName,ContactAddress,CreatorId,CreateTime,BizPartnerTypeId) + // VALUES('$contractno','$partyA',1,'TW','$phone',99999999,'$vat', '$partyA','$partyAaddress','$user_id',$createTime,'10')"; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->bindParam(':BizPartnerName', $partyA); //客戶名稱 + $stmt->bindParam(':WorkTelNo', $phone); + $stmt->bindParam(':TaxNo', $vat); + $stmt->bindParam(':EnterpriseName', $partyA); //企業名稱 + $stmt->bindParam(':ContactAddress', $partyAaddress); + // $stmt->bindParam(':EMail', $email); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); + + + + $sql = "INSERT INTO comCustomer (OrgId,BizPartnerTypeId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId) VALUES('1000','10','TWD',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime,'35')"; - $stmt = $connT8->prepare($sql); + // $sql = "INSERT INTO comCustomer + // (OrgId,BizPartnerTypeId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId) + // VALUES('1000','10','TWD','$contractno','$salesman','$user_id',1,'$partyAaddress','$createTime','35')"; + $stmt = $connT8->prepare($sql); - $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->bindParam(':PersonId', $salesman); - $stmt->bindParam(':CreatorId', $user_id); - $stmt->bindParam(':InvoiceAddress', $address); - $stmt->bindParam(':CreateTime', $createTime); - - $stmt->execute(); - } else { - // // 若客戶資料不為空,更新該客戶資訊。 - $sql = "UPDATE comCustomer SET + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->bindParam(':PersonId', $salesman); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':InvoiceAddress', $partyAaddress); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); + } else { + // // 若客戶資料不為空,更新該客戶資訊。 + $sql = "UPDATE comCustomer SET PersonId=:PersonId, InvoiceAddress=:InvoiceAddress, LastOperatorId=:LastOperatorId, LastOperateTime=:LastOperateTime WHERE BizPartnerId=:BizPartnerId "; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':PersonId', $salesman); - $stmt->bindParam(':InvoiceAddress', $address); - $stmt->bindParam(':LastOperatorId', $user_id); - $stmt->bindParam(':LastOperateTime', $createTime); - $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->execute(); + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':PersonId', $salesman); + $stmt->bindParam(':InvoiceAddress', $partyAaddress); + $stmt->bindParam(':LastOperatorId', $user_id); + $stmt->bindParam(':LastOperateTime', $createTime); + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->execute(); - $sql = "UPDATE comBusinessPartner SET + $sql = "UPDATE comBusinessPartner SET BizPartnerName=:BizPartnerName, WorkTelNo=:WorkTelNo, TaxNo=:TaxNo, EnterpriseName=:EnterpriseName, ContactAddress=:ContactAddress, - EMail=:EMail, LastOperatorId=:LastOperatorId, LastOperateTime=:LastOperateTime WHERE BizPartnerId = :BizPartnerId "; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':BizPartnerName', $partyA); - $stmt->bindParam(':WorkTelNo', $phone); - $stmt->bindParam(':TaxNo', $vat); - $stmt->bindParam(':EnterpriseName', $customer); - $stmt->bindParam(':ContactAddress', $partyAaddress); - $stmt->bindParam(':EMail', $email); - $stmt->bindParam(':LastOperatorId', $user_id); - $stmt->bindParam(':LastOperateTime', $createTime); - $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->execute(); - } + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':BizPartnerName', $partyA); + $stmt->bindParam(':WorkTelNo', $phone); + $stmt->bindParam(':TaxNo', $vat); + $stmt->bindParam(':EnterpriseName', $partyA); + $stmt->bindParam(':ContactAddress', $partyAaddress); + // $stmt->bindParam(':EMail', $email); + $stmt->bindParam(':LastOperatorId', $user_id); + $stmt->bindParam(':LastOperateTime', $createTime); + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->execute(); + } - $sql = "SELECT * FROM comProject WHERE ProjectId = :ProjectId"; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':ProjectId', $contractno); - $stmt->execute(); - $resultProject = $stmt->fetchAll(PDO::FETCH_ASSOC); - if (empty($resultProject)) { - //新增於 comProject。合約 table - $sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,CreateTime,CreatorId,IsInUsed) - VALUES(:ProjectId,:ProjectName,'C0',:CreateTime,:CreatorId,1)"; + $sql = "SELECT * FROM comProject WHERE ProjectId = :ProjectId"; $stmt = $connT8->prepare($sql); $stmt->bindParam(':ProjectId', $contractno); - $stmt->bindParam(':ProjectName', $customer); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->bindParam(':CreatorId', $user_id); $stmt->execute(); + $resultProject = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (empty($resultProject)) { + //新增於 comProject。合約 table + $sql = "INSERT INTO comProject(ProjectId,ProjectName,TypeId,CreateTime,CreatorId,IsInUsed) + VALUES(:ProjectId,:ProjectName,'C0',:CreateTime,:CreatorId,1)"; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':ProjectId', $contractno); + $stmt->bindParam(':ProjectName', $partyA); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->execute(); + } + + foreach ($elevators as $index => $elevator) { + $count = 1; + // 產品集成維護 + $facility_no = $facilityno[$index]; + $MaterialName = "$partyA($facility_no)"; + $sql = "INSERT INTO comMaterial + (FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime,IsInUsed) + VALUES ('1000',:MaterialId,'10','A',:CreatorId,:CreateTime,1)"; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':MaterialId', $facility_no); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); + + $sql = "INSERT INTO comMaterialGroup + (MaterialTypeId,MaterialId,MaterialName,MaterialCategoryId,IsInUsed,UnitId,CreatorId,CreateTime) + VALUES ('10',:MaterialId,:MaterialName,'A',1,'SET',:CreatorId,:CreateTime)"; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':MaterialId', $facility_no); + $stmt->bindParam(':MaterialName', $MaterialName); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); + + $sql = "INSERT INTO comMaterialPurchases + (Orgid,MaterialTypeId,MaterialId,CurrId,SUnitId,TaxId,CreatorId,CreateTime) + VALUES ('1000','10',:MaterialId,'TWD','SET','ST005',:CreatorId,:CreateTime)"; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':MaterialId', $facility_no); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); + + $sql = "INSERT INTO plsMaterialPlanData + (PlanRangeId,MaterialId,FOrgId,MaterialTypeId,CreatorId,CreateTime,DefaultDemandOrg) VALUES + (1000,:MaterialId,1000,10,:CreatorId,:CreateTime,1000) + "; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':MaterialId', $facility_no); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); + + $sql = "INSERT INTO comMaterialSales + (OrgId,MAterialTypeId,MaterialId,CurrId,SUnitId,SupplyOrgId,CreatorId,CreateTime,IsInUsed) VALUES + (1000,10,:MaterialId,'TWD','SET',1000,:CreatorId,:CreateTime,1) + "; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':MaterialId', $facility_no); + $stmt->bindParam(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); + + // 階段收款資訊 + $salOrderStagePay_row = []; + $equipment_total = 0; + $install_total = 0; + $equipment_total = $pay_arr['equipment_total']; + $install_total = $pay_arr['install_total']; + foreach ($pay_arr['elevotor_pay_detail'] as $key => $detail) { + $PayStage = $pay_kind[$detail['kind']]; + $PlanPercentage = intval($detail['pay_scale']) / 100; + $rows = [ + "PayStage" => "$PayStage", //收款階段 + "PlanPercentage" => $PlanPercentage, //計劃收款比例(%) + "PlanPayAmt" => $detail['amount'], //計劃收款金額 + "PlanPayDate" => 20240101, //計劃收款日期 1.第一筆都是簽約日 + "BillNo" => "$contractno", + "RowCode" => $key + 1, + "RowNo" => $key + 1, + "UnWriteOffOAmount" => $detail['amount'] //未核銷金額 + ]; + $salOrderStagePay_row[] = $rows; + } + + // 設備 + $row1 = [ + "TaxId" => "ST005", + "RequirementDate" => $signing_date, //出貨日期 + "ConsignmentDate" => $signing_date, //發貨日期 + "BillNo" => "$contractno", //合約號 + "RowCode" => $count, //全部筆數排列 + "ItemType" => 1, + "MaterialId" => "A40001", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) + "SUnitId" => "SET", + "SQuantity" => 1, //交易數量 + "SPrice" => $equipment_total //交易價格 + ]; + $count++; + // 安裝 + $row2 = [ + "TaxId" => "ST005", + "RequirementDate" => $signing_date, //出貨日期 + "ConsignmentDate" => $signing_date, //發貨日期 + "BillNo" => "$contractno", //合約號 + "RowCode" => $count, //全部筆數排列 + "ItemType" => 1, + "MaterialId" => "A40008", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) + "SUnitId" => "SET", + "SQuantity" => 1, //交易數量 + "SPrice" => $install_total //交易價格 + ]; + $count++; + // 產品(作番) + $row3 = [ + "TaxId" => "ST005", + "RequirementDate" => $signing_date, //出貨日期 + "ConsignmentDate" => $signing_date, //發貨日期 + "BillNo" => "$contractno", //合約號 + "RowCode" => $count, //全部筆數排列 + "ItemType" => 0, + "MaterialId" => "$facility_no", //1.設備(A40001)、2.安裝(A4008)、3.作番號(作番) + "SUnitId" => "SET", + "SQuantity" => 1, //交易數量 + "SPrice" => 0 //交易價格 + ]; + $count++; + $SubOrder_row[] = $row1; + $SubOrder_row[] = $row2; + $SubOrder_row[] = $row3; + $count++; + } + $MainSalesOrder_row = [ + "BillNo" => "$contractno", //合約單號 + "BillDate" => $signing_date, //簽約日期 + "TypeId" => "SO", // + "FOrgId" => "1000", + "OrgId" => "1000", + "ModeId" => "M", // T汰改 M新梯 + "BizPartnerId" => "$contractno", //客戶代碼 + "CurrId" => "TWD", + "CurrOAmount" => 1, + "CurrLAmount" => 1, + "PersonId" => "$user_id", //業務人員 + "DueToId" => "$contractno", //債務方 + "TradeConditionId" => "", + "TaxId" => "ST005", + "CreditorCompId" => "1001", + "CreditorOrgId" => "1000", + // "CompId" => "1001", + // "CreditorCurrOAmount" => 1, + // "CreditorCurrLAmount" => 1 + ]; + $MainSalesOrder = [ + "name" => "MainSalesOrder", + 'rows' => [$MainSalesOrder_row] + ]; + $SubOrder = [ + "name" => "SubOrder", + "rows" => $SubOrder_row + ]; + $salOrderStagePay = [ + "name" => "salOrderStagePay", + "rows" => [$salOrderStagePay_row] + ]; + + $API_body = []; + $API_body[] = $MainSalesOrder; + $API_body[] = $SubOrder; + $API_body[] = $salOrderStagePay; + echo ""; + print_r(json_encode($API_body, JSON_UNESCAPED_UNICODE)); + echo ""; + $api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData"; + + $result = T8salIncomeApply($API_body, $api_url); + echo ""; + print_r($result); + echo ""; + $connT8->commit(); + } catch (PDOException $e) { + $connT8->rollback(); + header("HTTP/1.1 500 Internal Server Error"); + die('Error!:' . $e->getMessage()); } } diff --git a/wms/contract/api/test copy.json b/wms/contract/api/test copy.json new file mode 100644 index 00000000..5df03461 --- /dev/null +++ b/wms/contract/api/test copy.json @@ -0,0 +1,113 @@ +[ + { + "name": "MainSalesOrder", + "rows": [ + { + "BillNo": "M24020076", + "BillDate": 20240305, + "TypeId": "SO", + "FOrgId": "1000", + "OrgId": "1000", + "ModeId": "M", + "BizPartnerId": "M24020076", + "CurrId": "TWD", + "CurrOAmount": 1, + "CurrLAmount": 1, + "PersonId": "M0225", + "DueToId": "M24020076", + "TradeConditionId": "", + "TaxId": "ST005", + "CreditorCompId": "1001", + "CreditorOrgId": "1000" + } + ] + }, + { + "name": "SubOrder", + "rows": [ + { + "TaxId": "ST005", + "RequirementDate": 20240305, + "ConsignmentDate": 20240305, + "BillNo": "M24020076", + "RowCode": 1, + "ItemType": 1, + "MaterialId": "A40001", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 910000 + }, + { + "TaxId": "ST005", + "RequirementDate": 20240305, + "ConsignmentDate": 20240305, + "BillNo": "M24020076", + "RowCode": 2, + "ItemType": 1, + "MaterialId": "A40008", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 390000 + }, + { + "TaxId": "ST005", + "RequirementDate": 20240305, + "ConsignmentDate": 20240305, + "BillNo": "M24020076", + "RowCode": 3, + "ItemType": 0, + "MaterialId": "4MW00705", + "SUnitId": "SET", + "SQuantity": 1, + "SPrice": 0 + } + ] + }, + { + "name": "salOrderStagePay", + "rows": [ + [ + { + "PayStage": "簽約", + "PlanPercentage": 0.2, + "PlanPayAmt": 260000, + "PlanPayDate": 20240101, + "BillNo": "M24020076", + "RowCode": 0, + "RowNo": 0, + "UnWriteOffOAmount": 260000 + }, + { + "PayStage": "貨抵工地", + "PlanPercentage": 0.5, + "PlanPayAmt": 650000, + "PlanPayDate": 20240101, + "BillNo": "M24020076", + "RowCode": 1, + "RowNo": 1, + "UnWriteOffOAmount": 650000 + }, + { + "PayStage": "試車完工", + "PlanPercentage": 0.2, + "PlanPayAmt": 260000, + "PlanPayDate": 20240101, + "BillNo": "M24020076", + "RowCode": 2, + "RowNo": 2, + "UnWriteOffOAmount": 260000 + }, + { + "PayStage": "交車", + "PlanPercentage": 0.1, + "PlanPayAmt": 130000, + "PlanPayDate": 20240101, + "BillNo": "M24020076", + "RowCode": 3, + "RowNo": 3, + "UnWriteOffOAmount": 130000 + } + ] + ] + } +] \ No newline at end of file diff --git a/wms/contract/api/test.json b/wms/contract/api/test.json index 04729705..c0585164 100644 --- a/wms/contract/api/test.json +++ b/wms/contract/api/test.json @@ -1,185 +1,66 @@ [ { - "name": "salIncomeApplyMaster", + //salSalesOrder + "name": "MainSalesOrder", "rows": [ { - "BillNo": "B23100060", - "BillDate": "20240122", - "OrgId": "1000", + "BillNo": "Z001", //合約單號 + "BillDate": 20210420, //簽約日期 + "TypeId": "SO", // "FOrgId": "1000", - "TypeId": "RAS", - "BpOrgId": "1000", - "BizPartnerId": "B23100060", + "OrgId": "1000", + "ModeId": "T", // T汰改 M新梯 + "BizPartnerId": "M0225", //創建人ID "CurrId": "TWD", "CurrOAmount": 1, "CurrLAmount": 1, - "PersonId": "M0065", - "DtOrgId": "1000", - "DueToId": "B23100060", + "PersonId": "M0225", //業務人員 + "DueToId": "512", //業務部門 + "TradeConditionId": "", "TaxId": "ST005", - "CompId": "1001", - "CreatorId": "M0225" + "CreditorCompId": "1000", + "CreditorOrgId": "1000", + "CreditorCurrOAmount": 1, + "CreditorCurrLAmount": 1, + "CompId": "1000" } ] }, { - "name": "salIncomeApplyDetail", + //salSalesOrderDetail + "name": "SubOrder", "rows": [ { - "BillNo": "B23100060", - "IncomeId": "A40003", - "TaxId": "ST005", - "RowCode": 1, - "RowNo": 1, - "ItemType": 1, - "SPrice": 1250, - "SQuantity": 1, - "ProjectId": "B23100060", - "FromSourceTag": 0, - "CU_MaterialId": "4TH53801" - }, - { - "BillNo": "B23100060", - "IncomeId": "A40003", - "TaxId": "ST005", - "RowCode": 2, - "RowNo": 2, - "ItemType": 1, - "SPrice": 1250, - "SQuantity": 1, - "ProjectId": "B23100060", - "FromSourceTag": 0, - "CU_MaterialId": "4TH53801" - }, - { - "BillNo": "B23100060", - "IncomeId": "A40003", - "TaxId": "ST005", - "RowCode": 3, - "RowNo": 3, - "ItemType": 1, - "SPrice": 1250, - "SQuantity": 1, - "ProjectId": "B23100060", - "FromSourceTag": 0, - "CU_MaterialId": "4TH53801" - }, - { - "BillNo": "B23100060", - "IncomeId": "A40003", - "TaxId": "ST005", - "RowCode": 4, - "RowNo": 4, - "ItemType": 1, - "SPrice": 1250, - "SQuantity": 1, - "ProjectId": "B23100060", - "FromSourceTag": 0, - "CU_MaterialId": "4TH53801" - }, - { - "BillNo": "B23100060", - "IncomeId": "A40003", - "TaxId": "ST005", - "RowCode": 5, - "RowNo": 5, - "ItemType": 1, - "SPrice": 1250, - "SQuantity": 1, - "ProjectId": "B23100060", - "FromSourceTag": 0, - "CU_MaterialId": "4TH53801" - }, - { - "BillNo": "B23100060", - "IncomeId": "A40003", - "TaxId": "ST005", - "RowCode": 6, - "RowNo": 6, - "ItemType": 1, - "SPrice": 1250, - "SQuantity": 1, - "ProjectId": "B23100060", - "FromSourceTag": 0, - "CU_MaterialId": "4TH53801" - }, - { - "BillNo": "B23100060", - "IncomeId": "A40003", + "SupplyCompId": "1001", + "SupplyOrgId": "1000", "TaxId": "ST005", - "RowCode": 7, - "RowNo": 7, - "ItemType": 1, - "SPrice": 1250, - "SQuantity": 1, - "ProjectId": "B23100060", - "FromSourceTag": 0, - "CU_MaterialId": "4TH53801" - }, - { - "BillNo": "B23100060", - "IncomeId": "A40003", - "TaxId": "ST005", - "RowCode": 8, - "RowNo": 8, - "ItemType": 1, - "SPrice": 1250, - "SQuantity": 1, - "ProjectId": "B23100060", - "FromSourceTag": 0, - "CU_MaterialId": "4TH53801" - }, - { - "BillNo": "B23100060", - "IncomeId": "A40003", - "TaxId": "ST005", - "RowCode": 9, - "RowNo": 9, - "ItemType": 1, - "SPrice": 1250, - "SQuantity": 1, - "ProjectId": "B23100060", - "FromSourceTag": 0, - "CU_MaterialId": "4TH53801" - }, - { - "BillNo": "B23100060", - "IncomeId": "A40003", - "TaxId": "ST005", - "RowCode": 10, - "RowNo": 10, - "ItemType": 1, - "SPrice": 1250, - "SQuantity": 1, - "ProjectId": "B23100060", - "FromSourceTag": 0, - "CU_MaterialId": "4TH53801" - }, - { - "BillNo": "B23100060", - "IncomeId": "A40003", - "TaxId": "ST005", - "RowCode": 11, - "RowNo": 11, - "ItemType": 1, - "SPrice": 1250, - "SQuantity": 1, - "ProjectId": "B23100060", - "FromSourceTag": 0, - "CU_MaterialId": "4TH53801" - }, + "RequirementDate": 20210420, //出貨日期 + "ConsignmentDate": 20210420, //發貨日期 + "DispatchCompId": "1001", + "DispatchOrgId": "1000", + "BillNo": "Z001", //合約號 + "RowCode": 1, //全部筆數排列 + "ItemType": 0, + "MaterialId": "Z001", //作番號 + "SUnitId": "SET", + "SQuantity": 1, //交易數量 + "SPrice": 1 //交易價格 + } + ] + }, + { + //salOrderStagePay + "name": "salOrderStagePay", + "rows": [ { - "BillNo": "B23100060", - "IncomeId": "A40003", - "TaxId": "ST005", - "RowCode": 12, - "RowNo": 12, - "ItemType": 1, - "SPrice": 1250, - "SQuantity": 1, - "ProjectId": "B23100060", - "FromSourceTag": 0, - "CU_MaterialId": "4TH53801" + "BillNo": "", + "RowCode": "", + "RowNo": "", + "PayStage": "ST003", //收款階段 + "PlanPercentage": "Z001", //計劃收款比例(%) + "PlanPayAmt": 1, //計劃收款金額 + "PlanPayDate": 1, //計劃收款日期 1.第一筆都是簽約日 + "UnWriteOffOAmount": 1 //未核銷金額 } ] } diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php index 9512cbc8..89077ffc 100644 --- a/wms/contract/api/testT8API.php +++ b/wms/contract/api/testT8API.php @@ -1,36 +1,286 @@ - - -地址轉經緯度 - - - - -輸入地址以獲取經緯度
-
"; +// print_r($data); +// echo ""; + +// echo "
"; +// print_r(json_encode($APIbody, JSON_UNESCAPED_UNICODE)); +// echo ""; +// exit(); + +$header = [ + "CHI_Authorization :" . $validation, + "GroupId:TEST" +]; +$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); // 使用 POST +curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($APIbody, JSON_UNESCAPED_UNICODE)); +$response = curl_exec($ch); + +if ($response === false) { + echo 'Curl error: ' . curl_error($ch); +} else { + $result = json_decode($response, true); + // 若 API 傳入失敗。 + if ($result['Status'] == 'Erroe') { + echo 'API傳入失敗,' . $result['ErrorMsg']; + print_r($result); + } else { + // print_r($result); + print_r($result); + } + print_r($result); +} + +curl_close($ch); diff --git a/wms/contract/contract-input.php b/wms/contract/contract-input.php index 10ef98d8..92aaf7d0 100644 --- a/wms/contract/contract-input.php +++ b/wms/contract/contract-input.php @@ -452,8 +452,11 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); - + + + \ No newline at end of file diff --git a/wms/contract/js/alpine.js b/wms/contract/js/alpine.js index 4c4d6d36..104ab4f7 100644 --- a/wms/contract/js/alpine.js +++ b/wms/contract/js/alpine.js @@ -810,7 +810,7 @@ const contractNewInput = () => { return { init() { }, data: { - contractno: 'M24020029', + contractno: 'M24020076', customer: '', manager: '', vat: '', @@ -827,6 +827,7 @@ const contractNewInput = () => { signing_date: '', //合約簽訂日期 elevators: [], // 電梯種類 Array elevators_detail_arr: [], // 電梯台數 Array + pay_arr: [], //電梯付款種類 nums: 0, //電梯數量 }, step: 1, @@ -902,6 +903,7 @@ const contractNewInput = () => { this.data.elevators = res.data.elevators; this.data.elevators_detail_arr = res.data.elevators_detail_arr; this.data.nums = res.data.nums; + this.data.pay_arr = res.data.pay_arr; } this.step = 2 this.isLoading = false @@ -929,6 +931,7 @@ const contractNewInput = () => { form.append('contract_type', this.data.contract_type); form.append('elevators_detail_arr', JSON.stringify(this.data.elevators_detail_arr)); form.append('elevators', JSON.stringify(this.data.elevators)); + form.append('pay_arr', JSON.stringify(this.data.pay_arr)); form.append('contracttype', 'm'); form.append('user_id', user_id); for (var i = 0; i < this.data.files.length; i++) {