diff --git a/wms/contract/api/getContractData.php b/wms/contract/api/getContractData.php index 9624bb51..c0f3078e 100644 --- a/wms/contract/api/getContractData.php +++ b/wms/contract/api/getContractData.php @@ -49,7 +49,9 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont $contractno = $_GET['contractno']; $sql_str = "SELECT a.*,b.lm_tel,b.uscc,b.manager,b.linkman FROM pricereview_main AS a LEFT JOIN hope_elevator_customer AS b ON a.contractno = b.vol_no - WHERE a.contractno = :contractno AND a.status != 'YN' "; + WHERE a.contractno = :contractno + -- AND a.status != 'YN' + "; $stmt = $conn->prepare($sql_str); $stmt->bindParam(':contractno', $contractno); $stmt->execute(); @@ -73,11 +75,11 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont $elevators_results = $stmt->fetchAll(PDO::FETCH_ASSOC); $elevators_detail_arr = []; $contract_elevator_qty = 0; + $sql = "SELECT * FROM pricereview_pay WHERE mid = :mid"; $stmt = $conn->prepare($sql); $stmt->bindParam(':mid', $mid); $stmt->execute(); - $pay_amount = $stmt->fetchAll(PDO::FETCH_ASSOC); $pay_arr = [ 'equipment_total' => 0, //設備款 @@ -121,6 +123,7 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont // print_r($pay_arr); // echo ""; + // 計算電梯數 foreach ($elevators_results as $keys) { $contract_elevator_qty += $keys['item_qty']; } @@ -206,32 +209,173 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont } } - -if (isset($_GET['contract_no']) && $_GET['contract_no'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 't') { - $contract_no = $_GET['contract_no']; +// 汰改 +if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 't') { try { - $sql = "SELECT * FROM pricereview_main AS a - WHERE a.kind='汰改' AND a.contract_no = :contract_no AND a.status='YY' - "; + $contractno = $_GET['contractno']; + $sql = "SELECT a.*,b.lm_tel,b.uscc,b.manager,b.linkman FROM pricereview_main AS a + LEFT JOIN hope_elevator_customer AS b ON a.contractno = b.vol_no + WHERE a.contractno = :contractno + -- AND a.status != 'YN' + "; $stmt = $conn->prepare($sql); - $stmt->bindParam(':contract_no', $contract_no); + $stmt->bindParam(':contractno', $contractno); $stmt->execute(); $contract = $stmt->fetch(PDO::FETCH_ASSOC); $id = $contract['id']; + // 查詢 manager and departno + $salesman = $contract['person']; + $sql = "SELECT * FROM account WHERE accountid = :accountid "; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':accountid', $salesman); + $stmt->execute(); + $account_detail = $stmt->fetch(PDO::FETCH_ASSOC); + $contract['manager'] = $account_detail['manager']; + $contract['salesman_departno'] = $account_detail['department_id']; - $sql = "SELECT * FROM pricerview_pay WHERE mid =:id"; + // 價格審查單-明細項目 + $mid = $contract['id']; + $sql = "SELECT * FROM pricereview_item WHERE mid = :mid AND item_group = 'A' "; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':mid', $mid); + $stmt->execute(); + $elevators_results = $stmt->fetchAll(PDO::FETCH_ASSOC); + $elevators_detail_arr = []; + $contract_elevator_qty = 0; + + + // 合約付款項目 + $sql = "SELECT * FROM pricereview_pay WHERE mid =:id"; $stmt = $conn->prepare($sql); $stmt->bindParam(':id', $id); $stmt->execute(); - $result = $stmt->fetch(PDO::FETCH_ASSOC); - $pay_kind = []; - foreach ($result as $result) { - $pay_kind[] = $result; + $pay_amount = $stmt->fetchAll(PDO::FETCH_ASSOC); + // $pay_kind[] = $result; + // $contract['pay_kind'] = $pay_kind; + $pay_arr = [ + 'equipment_total' => 0, //設備款 + 'install_total' => 0, //安裝款 + 'elevotor_pay_detail' => [] + ]; + // echo "
"; + // print_r($pay_amount); + // echo ""; + $elevotor_pay_detail = []; + foreach ($pay_amount as $i => $pay) { + if ($pay['pay_kind'] <= 4) { + // 設備款總價 + $pay_arr['equipment_total'] += $pay['pay_amount']; + if ($pay['pay_scale'] > 0) { + $elevotor_pay_detail = [ + 'pay_kind' => $pay['pay_kind'], + 'pay_scale' => $pay['pay_scale'], + 'pay_period' => $pay['pay_period'], + 'pay_amount' => $pay['pay_amount'] + ]; + // $elevotor_pay_detail['pay_scale'] = $pay['pay_scale']; + // $pay_arr['elevotor_pay_detail']['kind'] = $pay['pay_kind']; + // $pay_arr['elevotor_pay_detail']['pay_scale'] = $pay['pay_scale']; + // $pay_arr['elevotor_pay_detail']['pay_period'] = $pay['pay_period']; + // $pay_arr['elevotor_pay_detail']['amount'] = $pay['pay_amount']; + array_push($pay_arr['elevotor_pay_detail'], $elevotor_pay_detail); + } + } else { + $pay_arr['install_total'] += $pay['pay_amount']; + if ($pay['pay_scale'] > 0) { + $a = $pay['pay_kind']; + $elevotor_pay_detail = [ + 'pay_kind' => "$a", + 'pay_scale' => $pay['pay_scale'], + 'pay_period' => $pay['pay_period'], + 'pay_amount' => $pay['pay_amount'] + ]; + array_push($pay_arr['elevotor_pay_detail'], $elevotor_pay_detail); + } + } } - $contract['pay_kind'] = $pay_kind; - echo $contract; + + // 計算電梯數 + foreach ($elevators_results as $keys) { + $contract_elevator_qty += $keys['item_qty']; + } + + foreach ($elevators_results as $keys => $result) { + $item_no = $result['item_no']; //電梯項次 + // 電梯 OPTION + $sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='B' AND option_relate_spec = :item_no"; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':mid', $mid); + $stmt->bindParam(':item_no', $item_no); + $stmt->execute(); + $option_results = $stmt->fetchAll(PDO::FETCH_ASSOC); + $option_arr[] = $option_results; + // echo "
"; + // print_r($option_arr); + // echo ""; + if (!empty($option_results)) { + $result['option_price'] = 0; + // 電梯 OPTION 價格分別加到各台電梯 + foreach ($option_results as $key => $option) { + if ($option['item_qty'] == $result['item_qty']) { + $result['option_price'] += intval($option['item_unit_price']); + } else if ($option['item_qty'] / $result['item_qty'] != 1) { + $item_qty = intval($option['item_qty']) / intval($result['item_qty']); // 總option數量 / 總電梯台數 + $result['option_price'] += intval($option['item_unit_price']) * $item_qty; + } else { + $result['option_price'] += $option['item_unit_price'] * intval($option['item_qty']); + } + } + } + // 電梯 拆梯 價格分配到每台電梯 + $sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='D' AND option_relate_spec = :item_no"; + $stmt = $conn->prepare($sql); + $stmt->bindParam(':mid', $mid); + $stmt->bindParam(':item_no', $item_no); + $stmt->execute(); + $dismantle_arr = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (!empty($dismantle_arr)) { + $result['dismantle_price'] = 0; + // 電梯 OPTION 價格分別加到各台電梯 + foreach ($dismantle_arr as $key => $dismantle) { + if ($dismantle['item_qty'] == $result['item_qty']) { + $result['dismantle_price'] += intval($dismantle['item_unit_price']); + } else if ($dismantle['item_qty'] / $result['item_qty'] != 1) { + $item_qty = intval($dismantle['item_qty']) / intval($result['item_qty']); // 總option數量 / 總電梯台數 + $result['dismantle_price'] += intval($dismantle['item_unit_price']) * $item_qty; + } else { + $result['dismantle_price'] += $dismantle['item_unit_price'] * intval($dismantle['item_qty']); + } + } + } + + + $note = explode(',', $result['note']); + $result['spec'] = $note[0]; //型號 + $result['person'] = $note[1]; // 人承 + $result['floor'] = $note[2]; // 樓層 + $result['speed'] = $note[3]; // 速度 + $count_qty = $result['item_qty']; + for ($i = 0; $i < $count_qty; $i++) { + $result['elevator_price'] = round($result['item_price_ct'] / $result['item_qty']); //合約單台電提價格 + $result['commission_fee'] = round($contract['special_fee']) / $contract_elevator_qty; + $result['item_no'] = $i + 1; + $result['item_qty'] = 1; + array_push($elevators_detail_arr, $result); + } + } + $count = COUNT($elevators_detail_arr); + $contract['elevators'] = $elevators_results; + $contract['elevators_detail_arr'] = $elevators_detail_arr; + $contract['pay_arr'] = $pay_arr; + $contract['nums'] = $count; + // echo "
"; + // print_r($contract); + // echo ""; + + header('Content-Type: application/json'); + echo json_encode($contract); } catch (PDOException $e) { die("ERROR!!!: " . $e->getMessage()); } diff --git a/wms/contract/api/getFacilityNo.php b/wms/contract/api/getFacilityNo.php index 044d42cd..9d456747 100644 --- a/wms/contract/api/getFacilityNo.php +++ b/wms/contract/api/getFacilityNo.php @@ -404,7 +404,6 @@ class CreateFacilityNo $pdo = $this->connectionDB(); $pdo->exec('SET CHARACTER SET utf8mb4'); $connT8 = $this->connectionDB(); - // $connT8->exec('SET CHARACTER SET utf8mb4'); $sth = $pdo->prepare('SELECT * FROM `worksite` WHERE `facilityno` = ?'); $sth->bindValue(1, $facility_no); @@ -438,7 +437,6 @@ class CreateFacilityNo $pdo = $this->connectionDB(); $pdo->exec('SET CHARACTER SET utf8mb4'); $connT8 = $this->connectionT8DB(); - // $connT8->exec('SET CHARACTER SET utf8mb4'); $status = true; foreach ($facility_no as $row) { $sth = $pdo->prepare('SELECT * FROM `worksite` WHERE `facilityno` = ?'); diff --git a/wms/contract/api/newElevatorT8.php b/wms/contract/api/newElevatorT8.php index 86b1e0f3..e9e44168 100644 --- a/wms/contract/api/newElevatorT8.php +++ b/wms/contract/api/newElevatorT8.php @@ -355,10 +355,11 @@ function T8Insert($data, $facilityno, $connT8) } if (!empty($result) && ($result['Status'] == 'Fails' || $result['Status'] == 'Error')) { $Error_msg = $result['ErrorMsg']; - echo ""; - exit(); + // echo ""; + // exit(); // echo $result['ErrorMsg']; // echo ""; + echo $Error_msg; } } else { echo '資料已新增過,請洽資訊人員'; diff --git a/wms/contract/api/postRenovateContractData.php b/wms/contract/api/postRenovateContractData.php new file mode 100644 index 00000000..352e8f77 --- /dev/null +++ b/wms/contract/api/postRenovateContractData.php @@ -0,0 +1,4 @@ +"; +print_r($_POST); +echo ""; diff --git a/wms/contract/contract-renovate-input.php b/wms/contract/contract-renovate-input.php index 44f1f5be..f965dc75 100644 --- a/wms/contract/contract-renovate-input.php +++ b/wms/contract/contract-renovate-input.php @@ -1,24 +1,31 @@ prepare($sql); -// $stmt->bindParam(':depart_no', $depart_no); +$accounttype = "M"; +$sql_str = "SELECT accountid, name FROM account WHERE accounttype = :accounttype ORDER BY accountid"; +$stmt = $conn->prepare($sql_str); +$stmt->bindParam(":accounttype", $accounttype); $stmt->execute(); -$contractSalesman = $stmt->fetchAll(PDO::FETCH_ASSOC); -// echo '
'; -// print_r($contractSalesman); -// echo ''; +$persons = $stmt->fetchAll(PDO::FETCH_ASSOC); +$persons = array_map(function ($person) { + return [ + 'view' => $person['name'] . '-' . $person['accountid'], + 'value' => $person['accountid'], + 'name' => $person['name'] + ]; +}, $persons); ?> + + - +
未填寫
+未填寫
+未填寫
+未填寫
+未填寫
+未填寫
+未填寫
+未填寫
未填寫
+