prepare($sql_str); $stmt->bindParam(':vol_no', $contractno); $stmt->execute(); $contract = $stmt->fetch(PDO::FETCH_ASSOC); if (empty($contract)) { echo false; exit; } $apply_key = $contract['apply_key']; $sql_str = "SELECT * FROM con_maintance_examine_clear WHERE apply_key = :apply_key"; $stmt = $conn->prepare($sql_str); $stmt->bindParam(':apply_key', $apply_key); $stmt->execute(); $elevators = $stmt->fetchAll(PDO::FETCH_ASSOC); $count = COUNT($elevators); // foreach ($elevators as $key => $elevator) { // $elevator['discount'] = ($elevator['sold_price'] / $elevator['stand_price']) * 100; // } $contract['elevators'] = $elevators; $contract['num'] = $count; $contractResponse = json_encode($contract); // 設定回應標頭為 JSON header('Content-Type: application/json'); // 將 JSON 回應返回給客戶端 echo $contractResponse; // echo json_encode($contractResponse); } catch (PDOException $e) { die("ERROR!!!: " . $e->getMessage()); } } if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'm') { try { $contractno = $_GET['contractno']; $sql_str = "SELECT * FROM hope_elevator_customer WHERE vol_no = :vol_no ORDER BY created_at DESC"; $stmt = $conn->prepare($sql_str); $stmt->bindParam(':vol_no', $contractno); $stmt->execute(); $contract = $stmt->fetch(PDO::FETCH_ASSOC); $contractResponse = json_encode($contract); // 設定回應標頭為 JSON header('Content-Type: application/json'); // 將 JSON 回應返回給客戶端 echo $contractResponse; } catch (PDOException $e) { die("ERROR!!!: " . $e->getMessage()); } } if (!empty($_GET['contracttype']) && $_GET['contracttype'] == 'accountManger' && !empty($_GET['salesman'])) { try { $salesman = $_GET['salesman']; $sql = "SELECT manager FROM account WHERE accountid = :accountid"; $stmt = $conn->prepare($sql); $stmt->bindParam(':accountid', $salesman); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); header('Content-Type:application/json'); echo json_encode($result); } catch (PDOException $e) { die("ERROR!!!:" . $e->getMessage()); } }