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.
122 lines
4.8 KiB
122 lines
4.8 KiB
<?php
|
|
require_once('../conn.php');
|
|
if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'b') {
|
|
try {
|
|
$contractno = $_GET['contractno'];
|
|
$sql_str = "SELECT con_maintance_examine_apply.*, con_maintance_examine_clear.* FROM con_maintance_examine_apply
|
|
JOIN con_maintance_examine_clear on con_maintance_examine_apply.apply_key=con_maintance_examine_clear.apply_key
|
|
WHERE con_maintance_examine_apply.vol_no = :vol_no ;";
|
|
$sql_str = "SELECT * FROM con_maintance_examine_apply WHERE vol_no = :vol_no ORDER BY create_at DESC;";
|
|
$stmt = $conn->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);
|
|
$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 (isset($_GET['repair_no']) && $_GET['repair_no'] != '' && isset($_GET['contracttype']) && $_GET['contracttype'] == 'r') {
|
|
try {
|
|
$repair_no = $_GET['repair_no'];
|
|
$fail_arr = [];
|
|
$d_status = '1';
|
|
// 判斷單號是否在合約簽核已建立
|
|
$sql = "SELECT COUNT(*) AS num FROM contract_r_signed_back WHERE repair_no = :repair_no AND delete_status = :d_status ";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->bindParam(":repair_no", $repair_no);
|
|
$stmt->bindParam(":d_status", $d_status);
|
|
$stmt->execute();
|
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
$count = $result['num'];
|
|
if ($count >= 1) {
|
|
$fail_arr[] = '合約單號重複,請至契約管理(修理)查看。';
|
|
header("HTTP/1.1 422 Unprocessable Entity");
|
|
echo json_encode($fail_arr);
|
|
exit();
|
|
}
|
|
// 判斷單號是否在價格審查中以建立。
|
|
$sql = "SELECT COUNT(*) AS num FROM pricereview_repair_main WHERE repair_no = :repair_no";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->bindParam(":repair_no", $repair_no);
|
|
$stmt->execute();
|
|
$result2 = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
$count2 = $result2['num'];
|
|
if ($count2 == 0) {
|
|
$fail_arr[] = '找不到單號,請再確認。';
|
|
header("HTTP/1.1 422 Unprocessable Entity");
|
|
echo json_encode($fail_arr);
|
|
exit();
|
|
}
|
|
|
|
|
|
// $contractno = $_GET['contractno'];
|
|
$sql = "SELECT a.*,b.name,b.accountid
|
|
FROM pricereview_repair_main AS a
|
|
LEFT JOIN account AS b
|
|
ON a.repairerid = b.accountid
|
|
WHERE a.repair_no = :repair_no ";
|
|
$stmt = $conn->prepare($sql);
|
|
|
|
$stmt->bindParam(':repair_no', $repair_no);
|
|
$stmt->execute();
|
|
$contract = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
$contractResponse = json_encode($contract);
|
|
|
|
// 設定回應標頭為 JSON
|
|
header('Content-Type : appliction/json');
|
|
|
|
// 將 JSON 回應給客戶端
|
|
echo $contractResponse;
|
|
} catch (PDOException $e) {
|
|
die("ERROR!!:" . $e->getMessage());
|
|
}
|
|
}
|
|
|