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.
61 lines
1.7 KiB
61 lines
1.7 KiB
<?php
|
|
/**
|
|
* 取得價審單電梯項目
|
|
* @url /pricereview-item.php
|
|
* @method POST
|
|
* @return JSON
|
|
*
|
|
* request
|
|
* {
|
|
* "id"
|
|
* }
|
|
* id : pricereview_item.id
|
|
* respons json
|
|
* {
|
|
* "st" : "ok",
|
|
* "err" : ""
|
|
* }
|
|
**/
|
|
|
|
$rarr = array('st' => 'ok', 'err' => '');
|
|
|
|
try {
|
|
if (empty($_POST) || empty($_POST["id"])) throw new \Exception("id empty");
|
|
if (empty($_COOKIE["_m"])) throw new \Exception("user empty");
|
|
|
|
foreach ($_POST as $k => $v) {
|
|
$$k = htmlspecialchars(stripslashes(trim($v)));
|
|
}
|
|
require_once "database.php";
|
|
|
|
list($uid, $uname) = explode(";", unserialize($_COOKIE["_m"]));
|
|
$db_query = "select a.id, a.contractno, a.case_name, a.address, a.price_total from pricereview_main a where a.id not in (";
|
|
$db_query .= "select b.pr_main_id from contractapply_main b where b.pr_main_id = a.id) ";
|
|
$db_query .= "and a.id = '$id' and a.creater = '$uid' and a.last_check_result = 'Y'";
|
|
$res = mysqli_query($link, $db_query);
|
|
if (mysqli_num_rows($res) == 0) {
|
|
mysqli_free_result($res);
|
|
throw new \Exception("no data");
|
|
}
|
|
foreach ($res as $v) {
|
|
$rarr["contractno"] = $v["contractno"];
|
|
$rarr["case_name"] = $v["case_name"];
|
|
$rarr["address"] = $v["address"];
|
|
$rarr["price_total"] = $v["price_total"];
|
|
}
|
|
mysqli_free_result($res);
|
|
|
|
$db_query = "select id, item_no, item_group, item_spec, item_qty, item_price_bp from pricereview_item where mid = '$id' order by id";
|
|
$res = mysqli_query($link, $db_query);
|
|
foreach ($res as $v) {
|
|
//print_r($v);
|
|
$rarr["item"][] = $v;
|
|
}
|
|
mysqli_free_result($res);
|
|
}catch(\Exception $e) {
|
|
$rarr['st'] = 'err';
|
|
$rarr['err'] = $e->getMessage();
|
|
}
|
|
|
|
echo json_encode($rarr, JSON_UNESCAPED_UNICODE);
|
|
?>
|