You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

63 lines
1.6 KiB

<?php
/**
* 客戶資料
* @url /pricereview_contractno-api.php
* @method POST
* @return JSON
*
* request
* {
* "pa"
* }
* pa : 合約號
* respons json
* {
* "st" : "ok",
* "err" : ""
* }
**/
ob_start();
include "../header.php";
ob_end_clean();
$rarr = array("st" => "ok", "err" => "");
try {
if (empty($_POST) || empty($_POST["pa"])) throw new \Exception("parameter empty");
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
// 基本資料
$db_query = "SELECT a.address, a.repairerid, c.contractno, c.company, c.taxid FROM account a, contract c ";
$db_query .= "where a.accountid = c.customerid and c.contractno = '$pa'";
$res = mysqli_query($link, $db_query);
if ($row = mysqli_fetch_row($res)) {
$rarr["address"] = $row[0];
$rarr["repairerid"] = $row[1];
$rarr["contractno"] = $row[2];
$rarr["company"] = $row[3];
$rarr["taxid"] = $row[4];
}
mysqli_free_result($res);
// 電梯編號
$db_query = "select facilityno from facility where contractno = '$pa' order by facilityno";
$res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_row($res)) {
$rarr["faci"][] = $row[0];
}
mysqli_free_result($res);
if (!isset($rarr["contractno"])) {
$rarr["st"] = "err";
$rarr["err"] = "無資料!";
}
} catch (\Exception $e) {
$rarr["st"] = "err";
$rarr["err"] = $e->getMessage();
}
//print_r($rarr);exit;
echo json_encode($rarr, JSON_UNESCAPED_UNICODE);
exit;