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 . '
"; - 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) {