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.
 
 
 
 
 
 

201 lines
7.2 KiB

<!doctype html>
<html lang="en">
<!-- 主頁header -->
<?php
/*--- 處理session ----*/
include "include-session-security.php"; #確認session
/*
if(isset($_SESSION['user_id'])){
#echo $_SESSION['user_id'];
$customerid = $_SESSION['user_id'];
}
*/
/*--- 處理session ----*/
# 上傳圖檔
if (isset($_POST["MAX_FILE_SIZE"])){
include_once 'include-upload.func.php';
$fileInfo = $_FILES['myFile'];
// 呼叫封將好的 function
$newName = uploadFile($fileInfo);
# echo "-----------------";
#print_r($newName); # $newName代表檔案路徑,如果前面幾個字不是"uploads/"就代表沒有檔案或是出錯了,因此不能將此存入數據庫
}else{
$newName = "";
}
if (substr($newName , 0 , 8) != "uploads/"){
$file_path = "";
}else{
$file_path = $newName;
}
# 載入db.php來連結資料庫
require_once "db/database.php";
# 取得數據庫最大值
$data = array();
$sql_query = "select max(id) from repair";
$data = mysqli_query($link,$sql_query);
foreach($data as $data){
$id = $data['max(id)'];
}
#print_r($id);
#echo $id;
#$customerid = $_POST["customerid"];
$contractno = $_POST['contractno'];
$facilityno = $_POST['facilityno'];
$damage_detail = $_POST["damage_detail"];
$contact_person = $_POST["contact_person"];
$contact_number = $_POST["contact_number"];
$repairerid = $_POST['repairerid'];
$repairername = $_POST['repairername'];
$phone_call_help = $_POST['phone_call_help'];
$progress_flag = "C";
$create_date = date("Y-m-d H:i:s");
$fixnumber = "FIX" . $facilityno . strval(intval(strval($id)) + 1);
$data = array(); # 設置一個空陣列來放資料
#$sql_query = "INSERT INTO repair(fixnumber, customerid, contractno, facilityno, damage_detail, file_path, contact_person, contact_number, repairerid, repairername, phone_call_help, pregress_flag, create_date) VALUES ('$fixnumber', '$customerid', '$contractno', '$facilityno', '$damage_detail', '$file_path', '$contact_person', '$contact_number', '$repairerid', '$repairername', '$phone_call_help', '$pregress_flag', '$create_date')";
#$sql_query = "INSERT INTO repair(fixnumber, customerid, contractno, facilityno, damage_detail, file_path, contact_person, contact_number, repairerid, repairername, phone_call_help, pregress_flag, create_date) VALUES ('$fixnumber', '$customerid', '$contractno', '$facilityno', '$damage_detail', '$file_path', '$contact_person', '$contact_number', '$repairerid', '$repairername', '$phone_call_help', '$pregress_flag', '$create_date')";
$sql_query = "INSERT INTO repair (fixnumber, customerid, contractno, facilityno, damage_detail, file_path, contact_person, contact_number, repairerid, repairername, phone_call_help, progress_flag) " .
"values ('$fixnumber', '$user_id', '$contractno', '$facilityno', '$damage_detail', '$file_path', '$contact_person', '$contact_number', '$repairerid', '$repairername', '$phone_call_help', '$progress_flag')";
$data = mysqli_query($link,$sql_query); # 機房在combo table中的id (亦即每個保養項的ID)
//以下推送到客户端消息
$line_post_data = array(); # 設置一個空陣列來放資料is
$sql = "
SELECT
r.facilityno,
r.contractno,
f.address,
a.name,
a.tel,
f.repairerid,
f.repairername
FROM `repair` AS r
LEFT JOIN facility AS f
ON r.facilityno = f.facilityno
LEFT JOIN account AS a
ON r.customerid = a.accountid
ORDER BY r.id DESC
LIMIT 1
";
$line_post_data = mysqli_fetch_array(mysqli_query($link,$sql)); # 用mysqli_query方法執行(sql語法)將結果存在變數中
$access_token = array();
$access_token[] = "blymLDSO21gDaCXA6nJ2jf6fEZTNE0wEwANbLAhKMhM";
$TargetCount = count($access_token);
$Push_Content['message'] = $faultstate . "\n";
$Push_Content['message'] = $Push_Content['message'] . "電梯編號: " . $line_post_data['facilityno'] . "\n";
$Push_Content['message'] = $Push_Content['message'] . "合約編號: " . $line_post_data['contractno'] . "\n";
$Push_Content['message'] = $Push_Content['message'] . "電梯地址: " . $line_post_data['address'] . "\n";
$Push_Content['message'] = $Push_Content['message'] . "客戶名稱: " . $line_post_data['name'] . "\n";
$Push_Content['message'] = $Push_Content['message'] . "客戶電話: " . $line_post_data['tel'] . "\n";
$Push_Content['message'] = $Push_Content['message'] . "保養員: " . $line_post_data['repairername'] . "(" . $line_post_data['repairerid'] . ")". "\n";
$Push_Content['message'] = $Push_Content['message'] . "聯絡人: " . $contact_person . "\n";
$Push_Content['message'] = $Push_Content['message'] . "聯繫手機號: " . $contact_number . "\n";
$Push_Content['message'] = $Push_Content['message'] . "反應內容: " . $damage_detail . "\n";
for ($i = 0; $i < $TargetCount; $i++) {
$ch = curl_init("https://notify-api.line.me/api/notify");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($Push_Content));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Bearer ' . $access_token[$i]
));
$response_json_str = curl_exec($ch);
curl_close($ch);
}
//以上推送到客户端消息
include "include-header.php";
?>
<!-- * 主頁header -->
<body class="bg-white">
<!-- loader -->
<div id="loader">
<div class="spinner-border text-primary" role="status"></div>
</div>
<!-- * loader -->
<!-- App Header -->
<div class="appHeader no-border transparent position-absolute">
<!-- 已簽呈成功,不讓返回上一頁
<div class="left">
<a href="javascript:;" class="headerButton goBack">
<ion-icon name="chevron-back-outline"></ion-icon>
</a>
</div>
-->
<div class="pageTitle"></div>
<!--
<div class="right">
</div>
-->
</div>
<!-- * App Header -->
<!-- App Capsule -->
<div id="appCapsule">
<div class="alert alert-primary alert-dismissible fade show" role="alert">
<h4 class="alert-title">報修成功! (維修工單:<?php echo $fixnumber; ?>)</h4>
後續將立即派員維修!
<button type="button" class="close" data-dismiss="alert">
<ion-icon name="close-outline"></ion-icon>
</button>
</div>
<div class="login-form">
<div class="section">
<h4></h4>
<a href="app-owner-status.php?token=<?php echo $token; ?>"><button type="button" class="btn btn-success mr-1 mb-1">電梯狀態</button></a>
<a href="app-owner-repaircall.php?token=<?php echo $token; ?>"><button type="button" class="btn btn-primary mr-1 mb-1">再次報修</button></a>
<a href="app-owner-repaircall-list.php?token=<?php echo $token; ?>"><button type="button" class="btn btn-warning mr-1 mb-1">報修明細</button></a>
</div>
</div>
</div>
<!-- * App Capsule -->
<!-- 主頁頁尾 -->
<?php
include "include-footer.php";
mysqli_close($link); #代表結束連線
?>
<!-- * 主頁頁尾 -->
<!-- 主頁頁尾按鈕 -->
<?php
# include "include-bottom-menu.php";
?>
<!-- * 主頁頁尾按鈕 -->
<!-- ///////////// Js Files //////////////////// -->
<!-- Jquery -->
<?php
include "include-jsfiles.php";
?>
</body>
</html>