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.
 
 
 
 
 
 

84 lines
2.6 KiB

<?php
/**
* 取得電梯價目或保養價格
* @url /pricereview_facility-api.php
* @method POST
* @return JSON
*
* request
* {
* "fval"
* }
* fval : 電梯/保養,種類,人乘,停數,速度,開門方式
* respons json
* {
* "st" : "ok",
* "err" : ""
* }
**/
ob_start();
include "../header.php";
ob_end_clean();
$rarr = array('st' => 'ok', 'err' => '');
try {
if (empty($_POST) || empty($_POST["fval"])) throw new \Exception("parameter empty");
foreach ($_POST as $k => $v) {
$$k = htmlspecialchars(stripslashes(trim($v)));
}
list($source, $kind, $seat, $numberofstop, $speed, $op) = explode(",", $fval);
if (!$source || !$kind || !$seat) throw new \Exception("parameter empty[2]");
if ($source == "F") {
$db_query = "select id, price, price_mi, model from facility_price where kind = '$kind' and seat = '$seat' and numberofstop = '$numberofstop' ";
$db_query .= "and speed = '$speed' and status = 'Y'";
$res = mysqli_query($link, $db_query);
if ($row = mysqli_fetch_row($res)) {
$id = $row[0];
$price = $row[1];
$price_mi = $row[2];
$a=[$kind, $seat, $numberofstop, $op, $speed];
$ret = facility_spec([$kind, $seat, $numberofstop, $op, $speed]);
list($model, $weight) = explode(",", $ret);
}
mysqli_free_result($res);
if (!empty($id)) {
$rarr["id"] = $id;
$rarr["amt"] = $price;
$rarr["iamt"] = "1".$price_mi;
$rarr["model"] = $model;
$rarr["group"] = "A";
$rarr["weight"] = $weight;
} else {
$rarr['st'] = 'err';
$rarr['err'] = "無價格,請連絡資訊人員!";
}
} else if ($source == "M") {
$db_query = "select id, price_a_1 from facility_maintenance_price where kind = '$kind' and seat = '$seat' and numberofstop = '$numberofstop' ";
$db_query .= "and speed = '$speed' and status = 'Y'";
//echo $db_query;exit;
$res = mysqli_query($link, $db_query);
if ($row = mysqli_fetch_row($res)) {
$id = $row[0];
$price = $row[1];
}
mysqli_free_result($res);
if (!empty($id)) {
$rarr["id"] = $id;
$rarr["amt"] = $price;
} else {
$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;
?>