diff --git a/wms/T8_Authorization_from_bpm.php b/wms/T8_Authorization_from_bpm.php index 0c81c268..c3592c3d 100644 --- a/wms/T8_Authorization_from_bpm.php +++ b/wms/T8_Authorization_from_bpm.php @@ -1,8 +1,7 @@ "營銷人員銷售獎金-訂金段", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($sales_bonus * 0.2), #金額 "payment_schedul_due" => "deposit", #訂金已收款20% "payment_schedul_regulation" => "訂金已收款20%,發放總獎金20%" #發放規定 ]); - + #營銷人員銷售獎金水庫-----出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50% - array_push($bonus_array,[ + array_push($bonus_array, [ "bonus_type" => "營銷人員銷售獎金-出貨款段", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($sales_bonus * 0.5), #金額 "payment_schedul_due" => "shipping", #訂金已收款20% "payment_schedul_regulation" => "出貨前期所有款項已收齊,且出貨款已收款50%,發放總獎金50%" #發放規定 - ]); - + ]); + #營銷人員銷售獎金水庫-----驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30% - array_push($bonus_array,[ + array_push($bonus_array, [ "bonus_type" => "營銷人員銷售獎金-驗收款段", #獎金名稱 "bonus_receiver" => $sales_id, #發放人員 "bonus_amount" => round($sales_bonus * 0.3), #金額 "payment_schedul_due" => "acceptance", #訂金已收款20% "payment_schedul_regulation" => "驗收前期所有款項已收齊,且驗收款已收款30%,發放總獎金30%" #發放規定 - ]); + ]); #區域經理獎金水庫-----訂金已收款100%,發放總獎金50% - array_push($bonus_array,[ + array_push($bonus_array, [ "bonus_type" => "區域經理提成獎金-訂金段", #獎金名稱 "bonus_receiver" => $region_manger_id, #發放人員 "bonus_amount" => round($region_manager_bonus * 0.5), #金額 "payment_schedul_due" => "deposit", #訂金已收款100% "payment_schedul_regulation" => "訂金已收款100%,發放總獎金50%" #發放規定 - ]); - + ]); + #區域經理獎金水庫-----貨到工地款(含)之前所有款項已收款100%,發放總獎金50% - array_push($bonus_array,[ + array_push($bonus_array, [ "bonus_type" => "區域經理提成獎金-貨到工地款段", #獎金名稱 "bonus_receiver" => $region_manger_id, #發放人員 "bonus_amount" => round($region_manager_bonus * 0.5), #金額 "payment_schedul_due" => "deliveried", #貨到工地款(含)之前所有款項已收款100% "payment_schedul_regulation" => "貨到工地款(含)之前所有款項已收款100%,發放總獎金50%" #發放規定 - ]); + ]); $result_array = [ - "ver"=>$ver, #獎金版本 - "result_status"=>"success", #計算結果 - "bonus_array"=>$bonus_array #獎金水庫 - ]; - }else{ - array_push($bonus_array,[ + "ver" => $ver, #獎金版本 + "result_status" => "success", #計算結果 + "bonus_array" => $bonus_array #獎金水庫 + ]; + } else { + array_push($bonus_array, [ "bonus_type" => "error", #獎金名稱 "bonus_receiver" => "error", #發放人員 "bonus_amount" => 0, #金額 "payment_schedul_due" => "9999-1-1", #預計發放時間 "payment_schedul_regulation" => "error" #發放規定 ]); - + $result_array = [ - "ver"=>$ver, #獎金版本 - "result_status"=>"error", #計算結果 - "bonus_array"=>$bonus_array #獎金水庫 + "ver" => $ver, #獎金版本 + "result_status" => "error", #計算結果 + "bonus_array" => $bonus_array #獎金水庫 ]; }; - + return $result_array; }; - -?> \ No newline at end of file diff --git a/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0.php b/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0.php index 15f87514..82ea4798 100644 --- a/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0.php +++ b/wms/bonus/elevator_new/elevator_new_deal_bonus_v2_0.php @@ -10,7 +10,7 @@ 區域經理員工號($region_manger_id) 【2.函數中的變數說明】 -銷售點數($discount):作番賣價($elevator_knockdown_price) 除以 作番表價($elevator_list_price) +// 銷售點數($discount):作番賣價($elevator_knockdown_price) 除以 作番表價($elevator_list_price) 營業員獎金($sales_bonus) 區域經理提成獎金($region_manager_bonus) 獎金預計發放階段($payment_schedule_due):deposit(訂金)、shipping(出貨款)、deliveried(貨到工地款)、acceptance(驗收款) @@ -39,6 +39,7 @@ function elevator_new_deal_bonus_v2_0($ver, $contract_type, $elevator_type, $ele { $bonus_array = []; if ($ver == "2.0") { + $elevator_knockdown_price = round($elevator_knockdown_price / 1.05); //不含稅 $discount = round($elevator_knockdown_price / $elevator_list_price, 3); #銷售點數,取到小數點第三位。 #合約總類($contract_type):戰略客戶(strategy_customer)、一般客戶(general_customer) diff --git a/wms/contract/api/T8api.php b/wms/contract/api/T8api.php index 245a318d..88d8dffa 100644 --- a/wms/contract/api/T8api.php +++ b/wms/contract/api/T8api.php @@ -6,12 +6,13 @@ function T8salIncomeApply($data, $api_url) // $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; $validation = get_Auth(); - // echo '
';
-    // print_r(json_encode($data, JSON_UNESCAPED_UNICODE));
-    // echo '
'; + echo '
';
+    print_r($validation);
+    echo '
'; + // exit; $header = [ "CHI_Authorization :" . $validation, - "GroupId:TEST" + "GroupId:MASADA" ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL diff --git a/wms/contract/api/getFacilityNo.php b/wms/contract/api/getFacilityNo.php index 55df3c57..b4d0928f 100644 --- a/wms/contract/api/getFacilityNo.php +++ b/wms/contract/api/getFacilityNo.php @@ -378,16 +378,31 @@ class CreateFacilityNo * @param string|array $facility_no * @return boolean $status : true:沒重複 false:重複 */ + function checkFacilityRepeatStatus($facility_no) { + // worksite wipwholestatus + // 檢查 substring 後五碼 if (gettype($facility_no) == "string") { $pdo = $this->connectionDB(); $pdo->exec('SET CHARACTER SET utf8mb4'); - $sth = $pdo->prepare('SELECT * FROM `facility` WHERE `facilityno` = ?'); + $sth = $pdo->prepare('SELECT * FROM `worksite` WHERE `facilityno` = ?'); $sth->bindValue(1, $facility_no); $sth->execute(); - if ($sth->rowCount() == 0) + if ($sth->rowCount() == 0) { + return true; + } + $facility_no = substr($facility_no, -5); + echo $facility_no; + $pdo = $this->connectionDB(); + $pdo->exec('SET CHARACTER SET utf8mb4'); + $sth = $pdo->prepare("SELECT * FROM `wipwholestatus` WHERE `facilityno` LIKE '%?'"); + $sth->bindValue(1, '%' . $facility_no . '%'); + $sth->execute(); + if ($sth->rowCount() == 0) { return true; + } + return false; } if (gettype($facility_no) == "array") { @@ -395,11 +410,21 @@ class CreateFacilityNo $pdo->exec('SET CHARACTER SET utf8mb4'); $status = true; foreach ($facility_no as $row) { - $sth = $pdo->prepare('SELECT * FROM `facility` WHERE `facilityno` = ?'); + $sth = $pdo->prepare('SELECT * FROM `worksite` WHERE `facilityno` = ?'); $sth->bindValue(1, $row); $sth->execute(); if ($sth->rowCount() !== 0) $status = false; + + $row = substr($row, -5); + $pdo = $this->connectionDB(); + $pdo->exec('SET CHARACTER SET utf8mb4'); + $sth = $pdo->prepare("SELECT * FROM `wipwholestatus` WHERE `facilityno` LIKE ?"); + $sth->bindValue(1, '%' . $row . '%'); + $sth->execute(); + if ($sth->rowCount() != 0) { + $status = false; + } } return $status; } diff --git a/wms/contract/api/getT8NewContractData.php b/wms/contract/api/getT8NewContractData.php new file mode 100644 index 00000000..2d348558 --- /dev/null +++ b/wms/contract/api/getT8NewContractData.php @@ -0,0 +1,62 @@ +prepare($sql); +$stmt->execute(); +$result = $stmt->fetchAll(PDO::FETCH_ASSOC); +// echo "
";
+// print_r($result);
+// echo "
"; +// exit(); +$result_detail = []; +$result_master = []; +$result_arr = []; +foreach ($result as $key => $result) { + $no = $result['BillNo']; + $result_master['BillNo'] = $no; + $firstChar = substr($no, 0, 1); + if ($firstChar == 'M' && $key <= 100) { + $sql = "SELECT BizPartnerName FROM comBusinessPartner WHERE BizPartnerId = '$no' "; + $stmt = $connT8->prepare($sql); + $stmt->execute(); + $customer_name = $stmt->fetch(PDO::FETCH_ASSOC); + // $result_master[] = $result; + $sql = "SELECT + BillNo, -- 合約號 + PayStage, -- 收款階段 + PlanPercentage, -- 收款比例 + PlanPayAmt -- 收款金額 + FROM salOrderStagePay WHERE BillNo = '$no'"; + $stmt = $connT8->prepare($sql); + $stmt->execute(); + $Detail = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (!empty($Detail)) { + foreach ($Detail as $key => $detail) { + $detail['PlanPercentage'] = (float)$detail['PlanPercentage']; + $Detail[$key]['PlanPercentage'] = $detail['PlanPercentage']; // 比例轉小數第二位 + $Detail[$key]['PlanPayAmt'] = intval($detail['PlanPayAmt']); // 比例金額轉整數 + + } + + if (mb_substr($Detail[0]['PayStage'], 0, 2) == '寶佳') { + $result_master['customer_status'] = 'strategy_customer'; + } else if (!empty($customer_name) && mb_substr($customer_name['BizPartnerName'], 0, 1) == '【') { + $result_master['customer_status'] = 'strategy_customer'; + } else { + $result_master['customer_status'] = 'general_customer'; + } + + $result_master['total_price'] = intval($result['OAmount']); + $result_master['detail'] = $Detail; + $result_arr[] = $result_master; + } + } +} + +echo "
";
+print_r($result_arr);
+echo "
"; diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index 3b3d87f0..9522defe 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -1,3 +1,5 @@ + + makeBFacilityNo("T", $facility_arr, (int)$num); + echo json_encode($facilityno); + T8insert($_POST, $facilityno, $depId, $connT8); // if ($user_id == 'M0225') { // echo '
';
         //     print_r($facilityno);
         //     echo '
'; // exit(); // } - echo json_encode($facilityno); $fail_arr = []; if ($contractno === '') return $fail_arr[] = '合約號為必填'; if ($total_price == '') $fail_arr[] = '合約總價為必填'; @@ -100,10 +103,9 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c echo json_encode($fail_arr); exit(); } - T8insert($_POST, $facilityno, $depId); /// 獎金計算 $aaa = bonusCreate($_POST, $facilityno, $conn); - if ($aaa['status'] == 2) { + if (!empty($aaa) && $aaa['status'] == 2) { header("HTTP/1.1 422 Unprocessable Entity"); echo $aaa['data']; exit(); @@ -387,12 +389,13 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c } }; -function T8insert($data, $facilityno, $depId) +function T8insert($data, $facilityno, $depId, $connT8) { - require_once("../connt8.php"); + // require_once("../conn.php"); // 引入 T8 API 連線 require_once("./T8api.php"); + $contractno = !empty($data['contractno']) ? $data['contractno'] : null; // 合約號 $address = !empty($data['address']) ? $data['address'] : null; // 客戶地址 $customer = !empty($data['customer']) ? $data['customer'] : null; //企業名稱 @@ -414,7 +417,7 @@ function T8insert($data, $facilityno, $depId) $connT8->beginTransaction(); $sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId"; - $stmt = $conn->prepare($sql); + $stmt = $connT8->prepare($sql); $stmt->bindParam(':BizPartnerId', $contractno); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); @@ -428,6 +431,7 @@ function T8insert($data, $facilityno, $depId) echo 'Error'; exit; } + if (empty($result)) { // 若 客戶資料為空,新增一筆到 comCustomer // 新增客戶資料 @@ -589,25 +593,6 @@ function T8insert($data, $facilityno, $depId) $row++; // 計算分期款的收款月份 $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 = [ @@ -666,10 +651,10 @@ function T8insert($data, $facilityno, $depId) $API_body[] = $salIncomeApplyMaster; $API_body[] = $salIncomeApplyDetail; // 呼叫 API - // echo '
';
-    // print_r($API_body);
-    // echo '
'; - $api_url = 'https://erp.masada.com.tw:780/twWebAPI/V1/SALINCOMEAPPLY/PostERPData'; + echo '
';
+    print_r($API_body);
+    echo '
'; + $api_url = 'http://10.10.145.2:880/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 6fd5756c..359cbbb0 100644 --- a/wms/contract/api/postNewContractData.php +++ b/wms/contract/api/postNewContractData.php @@ -16,76 +16,77 @@ if ($_SERVER['REQUEST_METHOD'] != 'POST') { } //新梯簽回 if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'm') { - try { - $created_at = date('Y-m-d H:i:s'); - $created_by = $_POST["user_id"]; - $contractno = $_POST["contractno"]; - $customer = $_POST["customer"]; - $manager = $_POST["manager"]; - $vat = $_POST["vat"]; - $case_name = $_POST["case_name"]; - $linkman = $_POST["linkman"]; - $lm_tel = $_POST["lm_tel"]; - $address = $_POST["address"]; - $salesman = $_POST["salesman"]; - $qc = $_POST["qc"]; - $contracttype = $_POST["contracttype"]; - $elevators_nums = $_POST['nums']; - $area_no = $_POST['area_no']; - $elevators = json_decode($_POST['elevators'], JSON_UNESCAPED_UNICODE); - $elevators_detail_arr = json_decode($_POST['elevators_detail_arr'], JSON_UNESCAPED_UNICODE); - // echo "
";
-    // print_r($elevators_detail_arr);
-    // 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(); - // } - //create facility table - $createFacilityNo = new CreateFacilityNo(); - $dailyNecessities = [ - 'MAE100' => 'X', //小機房客梯 - 'MAM200' => 'W', //無機房客梯 - 'MAH100' => 'H', //小電梯 - 'MAQ100' => 'Z', //強趨梯 - 'MAF100' => 'F', //貨梯 - 'MAP100' => 'B', //平台梯 - ]; - $arr = []; - // 建立作番號 - foreach ($elevators_detail_arr as $elevator) { - // $spec = explode('-', $elevator['item_spec']); - $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(); - } - T8Insert($_POST, $facilityno, $connT8); + $created_at = date('Y-m-d H:i:s'); + $created_by = $_POST["user_id"]; + $contractno = $_POST["contractno"]; + $customer = $_POST["customer"]; + $manager = $_POST["manager"]; + $vat = $_POST["vat"]; + $case_name = $_POST["case_name"]; + $linkman = $_POST["linkman"]; + $lm_tel = $_POST["lm_tel"]; + $address = $_POST["address"]; + $salesman = $_POST["salesman"]; + $contracttype = $_POST["contracttype"]; + $elevators_nums = $_POST['nums']; + $area_no = $_POST['area_no']; + $elevators = json_decode($_POST['elevators'], JSON_UNESCAPED_UNICODE); + $elevators_detail_arr = json_decode($_POST['elevators_detail_arr'], JSON_UNESCAPED_UNICODE); + // echo "
";
+  // print_r($elevators_detail_arr);
+  // 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($elevators_detail_arr['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 = [ + 'MAE100' => 'X', //小機房客梯 + 'MAM200' => 'W', //無機房客梯 + 'MAH100' => 'H', //小電梯 + 'MAQ100' => 'Z', //強趨梯 + 'MAF100' => 'F', //貨梯 + 'MAP100' => 'B', //平台梯 + ]; + $arr = []; + // 建立作番號 + foreach ($elevators_detail_arr as $elevator) { + // $spec = explode('-', $elevator['item_spec']); + $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(); + // } + + T8Insert($_POST, $facilityno, $connT8); + // exit(); + try { $conn->beginTransaction(); //create account table @@ -122,8 +123,8 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $site_manager = $value['manage']; $warehouseid = $value['warehouseid']; $sql = "INSERT INTO Wipwholestatus - (contract_type,contractno,salesid,custom,accountid,site_manager,warehouseid,facilityno,weight,numberofpassenger,numberoffloor,opentype,speed,facility_kind,area_no,address,contract_arrival_date,real_contract_arrival_date,qc_official_type,creater,create_at) VALUES - ('A',:contractno,:salesid,:custom,:accountid,:site_manager,:warehouseid,:facilityno,:weight,:numberofpassenger,:numberoffloor,:opentype,:speed,:facility_kind,:area_no,:address,:contract_arrival_date,:real_contract_arrival_date,:qc_official_type,:creater,:create_at)"; + (contract_type,contractno,salesid,custom,accountid,site_manager,warehouseid,facilityno,weight,numberofpassenger,numberoffloor,opentype,speed,facility_kind,area_no,address,contract_arrival_date,real_contract_arrival_date,qc_official_type,creater,create_at,desin_spec_verify) VALUES + ('A',:contractno,:salesid,:custom,:accountid,:site_manager,:warehouseid,:facilityno,:weight,:numberofpassenger,:numberoffloor,:opentype,:speed,:facility_kind,:area_no,:address,:contract_arrival_date,:real_contract_arrival_date,:qc_official_type,:creater,:create_at,1)"; // $sql = "INSERT INTO Wipwholestatus // (contract_type,contractno,salesid,custom,accountid,facilityno,weight,numberofpassenger,numberoffloor,opentype,speed,facility_kind,address,contract_arrival_date,qc_official_type,creater,create_at) VALUES // ('A','$contractno','$salesman','$customer','$customer','$facilityno','$weight','$person','$floor','$open','$speed','$facility_kind','$address','$contract_arrival_date','$qc','$created_by','$created_at')"; @@ -153,6 +154,7 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c // echo "
";
       // print_r($lastId);
       // echo "
"; + // exit; if (!empty($lastId)) { echo '123'; // 寫入待簽程狀態 A (營業) @@ -180,111 +182,112 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c $stmt->execute(); // create table schedule - $contract_begin_date = ''; - $contract_end_date = ''; // 一年 - $comboNo = new CreateComboNo('em', $contract_begin_date, $contract_end_date); - $comboArr = json_decode($comboNo->getComboNo(), true); - foreach ($comboArr as $combo) { - $sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)'; - $stmt = $conn->prepare($sql_str); - $stmt->bindParam(':contractno', $contractno); - $stmt->bindParam(':facilityno', $facility_no); - $stmt->bindParam(':combono', $combo[0]); - $stmt->bindParam(':repairerid', $repairerid); - $stmt->bindParam(':repairername', $repairername); - $stmt->bindParam(':duedate', $combo[1]); - $stmt->bindParam(':creater', $creater); - $stmt->bindParam(':create_at', $create_at); - $result = $stmt->execute(); - } - } - - - - $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC"; - $stmt = $conn->prepare($sql_str); - $stmt->bindParam(":accountid", $salesman); - $stmt->execute(); - $saleman = $stmt->fetch(PDO::FETCH_ASSOC); - $salesman_name = $saleman['name']; - if (!empty($files)) { - $englisharr = range('a', 'z'); - $files = $_FILES['files']; - $newfiles = []; - foreach ($files as $file) { - $i = 0; //新陣列的索引編號 - foreach ($file as $key => $val) { - $newfiles[$i]['name'] = $files['name'][$key]; - $newfiles[$i]['type'] = $files['type'][$key]; - $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; - $newfiles[$i]['error'] = $files['error'][$key]; - $newfiles[$i]['size'] = $files['size'][$key]; - $i++; - } //foreach 第2層 end - } - $max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M) - $allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型 - $path = '../images/contracts/'; - if (!file_exists($path)) { - mkdir($path); - } - $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 - $datetime = (string)date('YmdHis'); - $files_id = 'm' . $datetime; // 保養=>b + 日期時間 - foreach ($newfiles as $key => $file) { - $randNum = rand(1000, 9999); - $randEnglish = $englisharr[rand(0, 25)]; - $file_name = 'm' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name']; - $msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name); - if ($msg == 1) { - $msg = '檔案傳送成功!'; - $sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)"; - $stmt = $conn->prepare($sql_str); - $stmt->bindParam(':files_id', $files_id); - $stmt->bindParam(':file_name', $file_name); - $stmt->bindParam(':file_mime', $file['type']); - $stmt->bindParam(':file_size', $file['size']); - $stmt->bindParam(':created_at', $created_at); - $stmt->bindParam(':created_by', $created_by); - $stmt->execute(); - } else { - throw new PDOException('檔案上傳失敗:' . $msg); + // $contract_begin_date = ''; + // $contract_end_date = ''; // 一年 + // $comboNo = new CreateComboNo('em', $contract_begin_date, $contract_end_date); + // $comboArr = json_decode($comboNo->getComboNo(), true); + // foreach ($comboArr as $combo) { + // $sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)'; + // $stmt = $conn->prepare($sql_str); + // $stmt->bindParam(':contractno', $contractno); + // $stmt->bindParam(':facilityno', $facility_no); + // $stmt->bindParam(':combono', $combo[0]); + // $stmt->bindParam(':repairerid', $repairerid); + // $stmt->bindParam(':repairername', $repairername); + // $stmt->bindParam(':duedate', $combo[1]); + // $stmt->bindParam(':creater', $creater); + // $stmt->bindParam(':create_at', $create_at); + // $result = $stmt->execute(); + // } + // } + + + + $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid ORDER BY create_at DESC"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(":accountid", $salesman); + $stmt->execute(); + $saleman = $stmt->fetch(PDO::FETCH_ASSOC); + $salesman_name = $saleman['name']; + if (!empty($files)) { + $englisharr = range('a', 'z'); + $files = $_FILES['files']; + $newfiles = []; + foreach ($files as $file) { + $i = 0; //新陣列的索引編號 + foreach ($file as $key => $val) { + $newfiles[$i]['name'] = $files['name'][$key]; + $newfiles[$i]['type'] = $files['type'][$key]; + $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; + $newfiles[$i]['error'] = $files['error'][$key]; + $newfiles[$i]['size'] = $files['size'][$key]; + $i++; + } //foreach 第2層 end } - $msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '
'; - $src_name = $path . $file['name']; - if (file_exists($src_name)) { - //副檔名 - $extname = pathinfo($src_name, PATHINFO_EXTENSION); - //主檔名 - $basename = basename($src_name, '.' . $extname); + $max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M) + $allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型 + $path = '../images/contracts/'; + if (!file_exists($path)) { + mkdir($path); + } + $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 + $datetime = (string)date('YmdHis'); + $files_id = 'm' . $datetime; // 保養=>b + 日期時間 + foreach ($newfiles as $key => $file) { + $randNum = rand(1000, 9999); + $randEnglish = $englisharr[rand(0, 25)]; + $file_name = 'm' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name']; + $msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name); + if ($msg == 1) { + $msg = '檔案傳送成功!'; + $sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':files_id', $files_id); + $stmt->bindParam(':file_name', $file_name); + $stmt->bindParam(':file_mime', $file['type']); + $stmt->bindParam(':file_size', $file['size']); + $stmt->bindParam(':created_at', $created_at); + $stmt->bindParam(':created_by', $created_by); + $stmt->execute(); + } else { + throw new PDOException('檔案上傳失敗:' . $msg); + } + $msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '
'; + $src_name = $path . $file['name']; + if (file_exists($src_name)) { + //副檔名 + $extname = pathinfo($src_name, PATHINFO_EXTENSION); + //主檔名 + $basename = basename($src_name, '.' . $extname); + } } + } else { + $files = null; } - } else { - $files = null; - } - $sql_str = "INSERT INTO contract_m_signed_back (contract_no, customer, manager, vat, case_name, linkman, lm_tel, address, salesman, salesman_name, files_id, created_at, created_by, qc_official_type) VALUES (:contract_no, :customer, :manager, :vat, :case_name, :linkman, :lm_tel, :address, :salesman, :salesman_name, :files_id, :created_at, :created_by, :qc)"; - $stmt = $conn->prepare($sql_str); - $stmt->bindParam(":contract_no", $contractno); - $stmt->bindParam(":customer", $customer); - $stmt->bindParam(":manager", $manager); - $stmt->bindParam(":vat", $vat); - $stmt->bindParam(":case_name", $case_name); - $stmt->bindParam(":linkman", $linkman); - $stmt->bindParam(":lm_tel", $lm_tel); - $stmt->bindParam(":address", $address); - $stmt->bindParam(":salesman", $salesman); - $stmt->bindParam(":salesman_name", $salesman_name); - $stmt->bindParam(":files_id", $files_id); - $stmt->bindParam(":created_at", $created_at); - $stmt->bindParam(":created_by", $created_by); - $stmt->bindParam(":qc", $qc); - $stmt->execute(); + $sql_str = "INSERT INTO contract_m_signed_back (contract_no, customer, manager, vat, case_name, linkman, lm_tel, address, salesman, salesman_name, files_id, created_at, created_by) VALUES (:contract_no, :customer, :manager, :vat, :case_name, :linkman, :lm_tel, :address, :salesman, :salesman_name, :files_id, :created_at, :created_by)"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(":contract_no", $contractno); + $stmt->bindParam(":customer", $customer); + $stmt->bindParam(":manager", $manager); + $stmt->bindParam(":vat", $vat); + $stmt->bindParam(":case_name", $case_name); + $stmt->bindParam(":linkman", $linkman); + $stmt->bindParam(":lm_tel", $lm_tel); + $stmt->bindParam(":address", $address); + $stmt->bindParam(":salesman", $salesman); + $stmt->bindParam(":salesman_name", $salesman_name); + $stmt->bindParam(":files_id", $files_id); + $stmt->bindParam(":created_at", $created_at); + $stmt->bindParam(":created_by", $created_by); + // $stmt->bindParam(":qc", $qc); + $stmt->execute(); - $result = $conn->commit(); - if ($result) { - header("HTTP/1.1 201 Created"); + $result = $conn->commit(); + if ($result) { + header("HTTP/1.1 201 Created"); + } } } catch (PDOException $e) { $conn->rollback(); @@ -295,109 +298,110 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c function T8Insert($data, $facilityno, $connT8) { - 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' => '交車' //交車 - // ]; - - $pay_kind = [ - '1' => '簽約', - '2' => '二次款', - '3' => '貨抵工地', - '4' => '材料其他', - '5' => '試車完工', //安裝完畢 - '6' => '交車' //交車 - ]; - - $sql = "SELECT * FROM comCustomer + // 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' => '交車' //交車 + // ]; + + $pay_kind = [ + '1' => '簽約', + '2' => '二次款', + '3' => '貨抵工地', + '4' => '材料其他', + '5' => '試車完工', //安裝完畢 + '6' => '交車' //交車 + ]; + + $sql = "SELECT * FROM comCustomer WHERE BizPartnerId = :BizPartnerId "; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':BizPartnerId', $contractno); - $stmt->execute(); - $result = $stmt->fetch(PDO::FETCH_ASSOC); + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':BizPartnerId', $contractno); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + + // 新增客戶 table + if (empty($result)) { + // 若 客戶資料為空,新增一筆到 comCustomer + // 新增客戶資料 - // 新增客戶 table - if (empty($result)) { - // 若 客戶資料為空,新增一筆到 comCustomer - // 新增客戶資料 - $sql = "INSERT INTO comBusinessPartner + $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(':CreatorId', $user_id); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->execute(); - + // $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(':CreatorId', $user_id); + $stmt->bindParam(':CreateTime', $createTime); + $stmt->execute(); - $sql = "INSERT INTO comCustomer - (OrgId,BizPartnerTypeId,ConditionId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId) - VALUES('1000','10','TWD','0008',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime,'35')"; - // $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); + $sql = "INSERT INTO comCustomer + (OrgId,BizPartnerTypeId,ConditionId,CurrId,BizPartnerId,PersonId,CreatorId,IsInUsed,InvoiceAddress,CreateTime,InvoiceId)VALUES + ('1000','10','0008','TWD',:BizPartnerId,:PersonId,:CreatorId,1,:InvoiceAddress,:CreateTime,'35')"; + // $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', $partyAaddress); - $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, ConditionId='0008', + CurrId='TWD', InvoiceAddress=:InvoiceAddress, LastOperatorId=:LastOperatorId, LastOperateTime=:LastOperateTime WHERE BizPartnerId=:BizPartnerId "; - $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(); + $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, @@ -407,47 +411,54 @@ function T8Insert($data, $facilityno, $connT8) LastOperateTime=:LastOperateTime WHERE BizPartnerId = :BizPartnerId "; - $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(); - } + $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"; + $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)"; $stmt = $connT8->prepare($sql); $stmt->bindParam(':ProjectId', $contractno); + $stmt->bindParam(':ProjectName', $partyA); + $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)"; + } + $sql = "SELECT * FROM salSalesOrder WHERE BillNo = :BillNo"; + $stmt = $connT8->prepare($sql); + $stmt->bindParam(':BillNo', $contractno); + $contractT8 = $stmt->fetch(PDO::FETCH_ASSOC); + if (empty($contractT8)) { + + foreach ($elevators as $index => $elevator) { + + $count = 1; + // 產品集成維護 + $facility_no = $facilityno[$index]; + $MaterialName = "$partyA($facility_no)"; + $contract_arrival_a = $elevator['contract_arrival_date']; + + $sql = "SELECT * FROM comMaterial WHERE MaterialId = '$facility_no'"; $stmt = $connT8->prepare($sql); - $stmt->bindParam(':ProjectId', $contractno); - $stmt->bindParam(':ProjectName', $partyA); - $stmt->bindParam(':CreateTime', $createTime); - $stmt->bindParam(':CreatorId', $user_id); $stmt->execute(); - } - $sql = "SELECT * FROM salSalesOrder WHERE BillNo = :BillNo"; - $stmt = $connT8->prepare($sql); - $stmt->bindParam(':BillNo', $contractno); - $contractT8 = $stmt->fetch(PDO::FETCH_ASSOC); - if (empty($contractT8)) { - foreach ($elevators as $index => $elevator) { - $count = 1; - // 產品集成維護 - $facility_no = $facilityno[$index]; - $MaterialName = "$partyA($facility_no)"; - $contract_arrival_a = $elevator['contract_arrival_date']; - + $MaterialisIt = $stmt->fetch(PDO::FETCH_ASSOC); + if (empty($MaterialisIt)) { $sql = "INSERT INTO comMaterial (FOrgid,MaterialId,MaterialTypeId,MaterialCategoryId,CreatorId,CreateTime,IsInUsed) VALUES ('1000',:MaterialId,'10','A',:CreatorId,:CreateTime,1)"; @@ -456,7 +467,6 @@ function T8Insert($data, $facilityno, $connT8) $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)"; @@ -495,155 +505,159 @@ function T8Insert($data, $facilityno, $connT8) $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']; - $count_a = 0; - $count_month = 1; - foreach ($pay_arr['elevotor_pay_detail'] as $key => $detail) { - if ($detail['kind'] == 3) { - $PlanPayDate = $contract_arrival_a; - } else if ($detail['kind'] > 3) { - $PlanPayDate = date("Y-m-d", strtotime($contract_arrival_a . '+' . $count_month . ' month')); - $count_month++; - } else { - $PlanPayDate = $signing_date; - $count_a++; - if ($count_a == 1) { - $PlanPayDate = date("Y-m-d", strtotime($signing_date . '+' . $count_a . ' month')); - } + } + // 階段收款資訊 + $salOrderStagePay_row = []; + $equipment_total = 0; + $install_total = 0; + $equipment_total = $pay_arr['equipment_total']; + $install_total = $pay_arr['install_total']; + $count_a = 0; + $count_month = 1; + foreach ($pay_arr['elevotor_pay_detail'] as $key => $detail) { + if ($detail['kind'] == 3) { + $PlanPayDate = $contract_arrival_a; + } else if ($detail['kind'] > 3) { + $PlanPayDate = date("Y-m-d", strtotime($contract_arrival_a . '+' . $count_month . ' month')); + $count_month++; + } else { + $PlanPayDate = $signing_date; + $count_a++; + if ($count_a == 1) { + $PlanPayDate = date("Y-m-d", strtotime($signing_date . '+' . $count_a . ' month')); } - - $contract_arrival_date = intval(str_replace("-", '', $PlanPayDate)); //貨到工地日 - - $PayStage = $pay_kind[$detail['kind']]; - $PlanPercentage = intval($detail['pay_scale']) / 100; - $rows = [ - "PayStage" => "$PayStage", //收款階段 - "PlanPercentage" => $PlanPercentage, //計劃收款比例(%) - "PlanPayAmt" => $detail['amount'], //計劃收款金額 - "PlanPayDate" => $contract_arrival_date, //計劃收款日期 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, //交易價格 - "CU_MaterialId" => $facility_no - ]; - $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, //交易價格 - "CU_MaterialId" => $facility_no - ]; - $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, //交易價格 - "CU_MaterialId" => $facility_no // 歸屬作番號 + $contract_arrival_date = intval(str_replace("-", '', $PlanPayDate)); //貨到工地日 + + $PayStage = $pay_kind[$detail['kind']]; + $PlanPercentage = intval($detail['pay_scale']) / 100; + $rows = [ + "PayStage" => "$PayStage", //收款階段 + "PlanPercentage" => $PlanPercentage, //計劃收款比例(%) + "PlanPayAmt" => $detail['amount'], //計劃收款金額 + "PlanPayDate" => $contract_arrival_date, //計劃收款日期 1.第一筆都是簽約日 + "BillNo" => "$contractno", + "RowCode" => $key + 1, + "RowNo" => $key + 1, + "UnWriteOffOAmount" => $detail['amount'] //未核銷金額 ]; - $count++; - $SubOrder_row[] = $row1; - $SubOrder_row[] = $row2; - $SubOrder_row[] = $row3; - $count++; + $salOrderStagePay_row[] = $rows; } - $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" => "$salesman", //業務人員 - "DueToId" => "$contractno", //債務方 - "TradeConditionId" => "", + + // 設備 + $row1 = [ "TaxId" => "ST005", - "CreditorCompId" => "1001", - "CreditorOrgId" => "1000", - "CreatorId" => "$user_id" - // "CompId" => "1001", - // "CreditorCurrOAmount" => 1, - // "CreditorCurrLAmount" => 1 - ]; - $MainSalesOrder = [ - "name" => "MainSalesOrder", - 'rows' => [$MainSalesOrder_row] + "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, //交易價格 + "CU_MaterialId" => $facility_no ]; - $SubOrder = [ - "name" => "SubOrder", - "rows" => $SubOrder_row + $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, //交易價格 + "CU_MaterialId" => $facility_no ]; - $salOrderStagePay = [ - "name" => "salOrderStagePay", - "rows" => $salOrderStagePay_row + $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, //交易價格 + "CU_MaterialId" => $facility_no // 歸屬作番號 ]; + $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" => "$salesman", //業務人員 + "DueToId" => "$contractno", //債務方 + "TradeConditionId" => "", + "TaxId" => "ST005", + "CreditorCompId" => "1001", + "CreditorOrgId" => "1000", + "CreatorId" => "$user_id" + // "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 "
"; - if ($result['Status'] == 'Fails' || $result['Status'] == 'Error') { - echo $result['ErrorMsg']; - } - } else { - echo '資料已新增過,請洽資訊人員'; + $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"; + // $api_url = "http://127.0.0.1:880/twWebAPI/V1/SALSALESORDER/PostERPData"; + $api_url = 'http://10.10.145.2:880/twWebAPI/V1/SALSALESORDER/PostERPData'; + + $result = T8salIncomeApply($API_body, $api_url); + echo "
";
+    print_r($result);
+    echo "
"; + if (!empty($result) && ($result['Status'] == 'Fails' || $result['Status'] == 'Error')) { + echo $result['ErrorMsg']; } - $connT8->commit(); - } catch (PDOException $e) { - $connT8->rollback(); - header("HTTP/1.1 500 Internal Server Error"); - die('Error!:' . $e->getMessage()); + } else { + echo '資料已新增過,請洽資訊人員'; + // exit(); } + $connT8->commit(); + // } catch (PDOException $e) { + // $connT8->rollback(); + // header("HTTP/1.1 500 Internal Server Error"); + // die('Error!:' . $e->getMessage()); + // } } @@ -698,7 +712,6 @@ function BounsCount($data, $conn, $facilityno) 'total' => $elevator_list_price, 'fee_per_st' => $elevator_knockdown_price ]; - if (!empty($result_bonus)) { if ($result_bonus['result_status'] != "error") { foreach ($result_bonus['bonus_array'] as $i => $result) { @@ -748,9 +761,6 @@ function BounsCount($data, $conn, $facilityno) $salesman, $manager ); - // echo '
';
-        // print_r($result_bonus);
-        // echo '
'; $facility_no = $facilityno[$key]; $bonus_json = [ 'contract_type' => $type, diff --git a/wms/contract/api/test copy.json b/wms/contract/api/test copy.json index b9dd2f3f..cb1ba7c7 100644 --- a/wms/contract/api/test copy.json +++ b/wms/contract/api/test copy.json @@ -3,18 +3,18 @@ "name": "MainSalesOrder", "rows": [ { - "BillNo": "M23110121", - "BillDate": 20240313, + "BillNo": "M24020076", + "BillDate": 20240320, "TypeId": "SO", "FOrgId": "1000", "OrgId": "1000", "ModeId": "M", - "BizPartnerId": "M23110121", + "BizPartnerId": "M24020076", "CurrId": "TWD", "CurrOAmount": 1, "CurrLAmount": 1, - "PersonId": "M0042", - "DueToId": "M23110121", + "PersonId": "M0073", + "DueToId": "M24020076", "TradeConditionId": "", "TaxId": "ST005", "CreditorCompId": "1001", @@ -28,315 +28,42 @@ "rows": [ { "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", + "RequirementDate": 20240320, + "ConsignmentDate": 20240320, + "BillNo": "M24020076", "RowCode": 1, "ItemType": 1, "MaterialId": "A40001", "SUnitId": "SET", "SQuantity": 1, - "SPrice": 3904000, - "CU_MaterialId": "4MH00836" + "SPrice": 910000, + "CU_MaterialId": "4MW00001" }, { "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", + "RequirementDate": 20240320, + "ConsignmentDate": 20240320, + "BillNo": "M24020076", "RowCode": 2, "ItemType": 1, "MaterialId": "A40008", "SUnitId": "SET", "SQuantity": 1, - "SPrice": 976000, - "CU_MaterialId": "4MH00836" + "SPrice": 390000, + "CU_MaterialId": "4MW00001" }, { "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", + "RequirementDate": 20240320, + "ConsignmentDate": 20240320, + "BillNo": "M24020076", "RowCode": 3, "ItemType": 0, - "MaterialId": "4MH00836", + "MaterialId": "4MW00001", "SUnitId": "SET", "SQuantity": 1, "SPrice": 0, - "CU_MaterialId": "4MH00836" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 1, - "ItemType": 1, - "MaterialId": "A40001", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 3904000, - "CU_MaterialId": "4MH00837" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 2, - "ItemType": 1, - "MaterialId": "A40008", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 976000, - "CU_MaterialId": "4MH00837" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 3, - "ItemType": 0, - "MaterialId": "4MH00837", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 0, - "CU_MaterialId": "4MH00837" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 1, - "ItemType": 1, - "MaterialId": "A40001", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 3904000, - "CU_MaterialId": "4MH00838" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 2, - "ItemType": 1, - "MaterialId": "A40008", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 976000, - "CU_MaterialId": "4MH00838" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 3, - "ItemType": 0, - "MaterialId": "4MH00838", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 0, - "CU_MaterialId": "4MH00838" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 1, - "ItemType": 1, - "MaterialId": "A40001", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 3904000, - "CU_MaterialId": "4MH00839" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 2, - "ItemType": 1, - "MaterialId": "A40008", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 976000, - "CU_MaterialId": "4MH00839" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 3, - "ItemType": 0, - "MaterialId": "4MH00839", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 0, - "CU_MaterialId": "4MH00839" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 1, - "ItemType": 1, - "MaterialId": "A40001", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 3904000, - "CU_MaterialId": "4MH00840" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 2, - "ItemType": 1, - "MaterialId": "A40008", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 976000, - "CU_MaterialId": "4MH00840" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 3, - "ItemType": 0, - "MaterialId": "4MH00840", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 0, - "CU_MaterialId": "4MH00840" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 1, - "ItemType": 1, - "MaterialId": "A40001", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 3904000, - "CU_MaterialId": "4MH00841" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 2, - "ItemType": 1, - "MaterialId": "A40008", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 976000, - "CU_MaterialId": "4MH00841" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 3, - "ItemType": 0, - "MaterialId": "4MH00841", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 0, - "CU_MaterialId": "4MH00841" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 1, - "ItemType": 1, - "MaterialId": "A40001", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 3904000, - "CU_MaterialId": "4MH00842" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 2, - "ItemType": 1, - "MaterialId": "A40008", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 976000, - "CU_MaterialId": "4MH00842" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 3, - "ItemType": 0, - "MaterialId": "4MH00842", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 0, - "CU_MaterialId": "4MH00842" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 1, - "ItemType": 1, - "MaterialId": "A40001", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 3904000, - "CU_MaterialId": "4MH00843" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 2, - "ItemType": 1, - "MaterialId": "A40008", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 976000, - "CU_MaterialId": "4MH00843" - }, - { - "TaxId": "ST005", - "RequirementDate": 20240313, - "ConsignmentDate": 20240313, - "BillNo": "M23110121", - "RowCode": 3, - "ItemType": 0, - "MaterialId": "4MH00843", - "SUnitId": "SET", - "SQuantity": 1, - "SPrice": 0, - "CU_MaterialId": "4MH00843" + "CU_MaterialId": "4MW00001" } ] }, @@ -346,52 +73,42 @@ { "PayStage": "簽約", "PlanPercentage": 0.2, - "PlanPayAmt": 976000, - "PlanPayDate": 20240413, - "BillNo": "M23110121", + "PlanPayAmt": 260000, + "PlanPayDate": 20240420, + "BillNo": "M24020076", "RowCode": 1, "RowNo": 1, - "UnWriteOffOAmount": 976000 + "UnWriteOffOAmount": 260000 }, { - "PayStage": "二次款", - "PlanPercentage": 0.4, - "PlanPayAmt": 1952000, - "PlanPayDate": 20240313, - "BillNo": "M23110121", + "PayStage": "貨抵工地", + "PlanPercentage": 0.5, + "PlanPayAmt": 650000, + "PlanPayDate": 20241220, + "BillNo": "M24020076", "RowCode": 2, "RowNo": 2, - "UnWriteOffOAmount": 1952000 + "UnWriteOffOAmount": 650000 }, { - "PayStage": "貨抵工地", + "PayStage": "試車完工", "PlanPercentage": 0.2, - "PlanPayAmt": 976000, - "PlanPayDate": 20241104, - "BillNo": "M23110121", + "PlanPayAmt": 260000, + "PlanPayDate": 20250120, + "BillNo": "M24020076", "RowCode": 3, "RowNo": 3, - "UnWriteOffOAmount": 976000 + "UnWriteOffOAmount": 260000 }, { - "PayStage": "試車完工", + "PayStage": "交車", "PlanPercentage": 0.1, - "PlanPayAmt": 488000, - "PlanPayDate": 20241204, - "BillNo": "M23110121", + "PlanPayAmt": 130000, + "PlanPayDate": 20250220, + "BillNo": "M24020076", "RowCode": 4, "RowNo": 4, - "UnWriteOffOAmount": 488000 - }, - { - "PayStage": "交車", - "PlanPercentage": 0.1, - "PlanPayAmt": 488000, - "PlanPayDate": 20250104, - "BillNo": "M23110121", - "RowCode": 5, - "RowNo": 5, - "UnWriteOffOAmount": 488000 + "UnWriteOffOAmount": 130000 } ] } diff --git a/wms/contract/api/testT8API.php b/wms/contract/api/testT8API.php index e9d2f04f..a77acf8b 100644 --- a/wms/contract/api/testT8API.php +++ b/wms/contract/api/testT8API.php @@ -66,34 +66,35 @@ require_once("../../T8_Authorization_from_bpm.php"); $api_url = "https://erp.masada.com.tw:780/twWebAPI/V1/SALSALESORDER/PostERPData"; $validation = get_Auth(); -// $header = [ -// "CHI_Authorization :" . $validation, -// "GroupId:TEST" -// ]; -// $url = "https://erp.masada.com.tw:780/twWebAPI/V1/GLFEEWRITEOFF/DeleteERPData?pkValue=M24020032"; +$header = [ + "CHI_Authorization :" . $validation, + "GroupId:MASADA" +]; +$url = "https://erp.masada.com.tw:780/twWebAPI/V1/GLFEEWRITEOFF/DeleteERPData?pkValue=1000,M24020076"; -// $ch = curl_init(); -// curl_setopt($ch, CURLOPT_URL, $url); -// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -// 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); -// // 若 API 傳入失敗。 -// if ($result['Status'] == 'Erroe') { -// echo 'API傳入失敗,' . $result['ErrorMsg']; -// print_r($result); -// } else { -// // print_r($result); -// print_r($result); -// } -// print_r($result); -// } +$ch = curl_init(); +curl_setopt($ch, CURLOPT_URL, $url); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_HTTPHEADER, $header); -// curl_close($ch); -// exit(); +$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); +exit(); $contract_no = "M24020003"; // $contract_no = "M24010109"; $MainSalesOrder_row = [ diff --git a/wms/contract/conn.php b/wms/contract/conn.php index ed80762b..bbfd1c50 100644 --- a/wms/contract/conn.php +++ b/wms/contract/conn.php @@ -34,7 +34,11 @@ try { //設定主動以警告的形式報錯 $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8TEST", "M0225", "IFFBU1E="); + // $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8TEST", "M0225", "IFFBU1E="); + // $connT8 = new PDO("sqlsrv:Server=10.10.145.2;Database=T8MASADA", "masada", "@m222222"); + $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "masada", "@m222222"); + + if ($connT8) { $connT8->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } diff --git a/wms/contract/contract-newelevator-input.php b/wms/contract/contract-newelevator-input.php index 70d83b32..634dfd3b 100644 --- a/wms/contract/contract-newelevator-input.php +++ b/wms/contract/contract-newelevator-input.php @@ -179,7 +179,7 @@ $persons = array_map(function ($person) { 電梯速度 - + 電梯樓停 diff --git a/wms/contract/js/alpine.js b/wms/contract/js/alpine.js index d55726a6..c3cb39c8 100644 --- a/wms/contract/js/alpine.js +++ b/wms/contract/js/alpine.js @@ -819,8 +819,6 @@ const contractNewInput = () => { lm_tel: '', address: '', salesman: '', - qc: '', - qc: '', price_total: '', //合約總價 files: [], contract_type: '1', @@ -869,7 +867,7 @@ const contractNewInput = () => { this.data.elevators_detail_arr[i].latitude = ''; // 經度 this.data.elevators_detail_arr[i].longitude = ''; // 緯度 this.data.elevators_detail_arr[i].manage = ''; // 工地負責人 - this.data.elevators_detail_arr[i].qc = ''; // QC和官檢 + this.data.elevators_detail_arr[i].qc = 'QO'; // QC和官檢 this.data.elevators_detail_arr[i].contract_arrival_date = this.data.contract_arrival_date; //合約交期(到工地) // this.data.elevators_detail_arr[i].area_no = ''; //區域 } @@ -901,7 +899,7 @@ const contractNewInput = () => { this.data.lm_tel = res.data.lm_tel this.data.address = res.data.address this.data.salesman = res.data.person - this.data.qc = res.data.qc; + // this.data.qc = res.data.qc; this.data.price_total = res.data.price_total; this.data.elevators = res.data.elevators; this.data.elevators_detail_arr = res.data.elevators_detail_arr; @@ -929,7 +927,6 @@ const contractNewInput = () => { form.append('lm_tel', this.data.lm_tel); form.append('address', this.data.address); form.append('salesman', this.data.salesman); - form.append('qc', this.data.qc); form.append('signing_date', this.data.signing_date); form.append('nums', this.data.nums); form.append('price_total', this.data.price_total); @@ -961,7 +958,7 @@ const contractNewInput = () => { this.customize = false } else { - alert('儲存失敗!可能為以下錯誤:\n' + res.data) + alert('儲存失敗!') } this.isLoading = false }).catch(error => { @@ -1025,7 +1022,7 @@ const contractInput = () => { disabled: false, //資料庫是否有電梯數量資料 elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期 payType: '', //付款方式 - contract_type: '' + contract_type: 'new' // bonus_verson: 2.1, // manager: '', // regular_contract_manger_id: '',