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.
 
 
 
 
 
 

162 lines
5.2 KiB

<?php
include "header.php";
$maintainance_arr = ["A" => "全包", "B" => "半包", "C" => "清包", "D" => "2個月保養一次"];
// 設置一個空陣列來放資料
$data = $account_arr = array();
$db_query = "select accountid, name from account where accounttype = 'B' order by id";
$res = mysqli_query($link, $db_query);
while ($row = mysqli_fetch_array($res)) {
$account_arr[$row["accountid"]] = $row["name"];
}
mysqli_free_result($res);
// sql語法存在變數中
$sql = "select * from schedule_check order by id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link, $sql);
if ($user_auth&2) {
?>
<p>
<a href="#" id="btn_import" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-refresh"></span>
</a>
</p>
<?php
}
if ($data) {
?>
<style>
table {
table-layout:fixed;
width: 100%;
}
td {
word-wrap:break-word;
}
img {
width:125px;
}
.width_style_1 {
width:125px;
}
table {
width:100%;
}
th, td {
text-align: center;
}
#table_index_filter {
float:right;
}
#table_index_paginate {
float:right;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
}
</style>
<script>
$(function() {
$('#btn_import').click(function(){
var formdata = new FormData();
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
data = JSON.parse(this.responseText);
if (data.st == 'ok') {
alert("資料已匯入!");
location.reload();
return;
} else {
alert("系統忙碌,請重新操作!");
return;
}
}
}
xhr.open('GET','schedule_check-import.php?<?php echo $token_link; ?>',true);
xhr.send(formdata);
});
});
</script>
<div style="overflow-x:auto;">
<table id="table_index" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>項次</th>
<th>電梯ID</th>
<th class="text-danger">預排抽查日</th>
<th>實際抽查日</th>
<th>抽查分數</th>
<th>交車日期</th>
<th>許可證到期日</th>
<th>現場名稱</th>
<th>保養別</th>
<th>機型</th>
<th>保養人員</th>
<!--<th>建檔人</th>-->
<th>建檔時間</th>
<?php if ($user_auth&2) { ?>
<th>修改</th>
<th>刪除</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
foreach($data as $data) :
$sql = "select f.maintainance, f.facility_kind, f.repairerid, f.takecertificatedate, f.licensedate, c.company from facility f, contract c where f.contractno = c.contractno and f.facilityno = '".$data['facilityno']."'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
list($maintainance, $facility_kind, $repairerid, $takecertificatedate, $licensedate, $company) = $row;
mysqli_free_result($res);
?>
<tr>
<td><?php echo $data['id']; ?></td>
<td><?php echo $data['facilityno']; ?></td>
<td><?php echo $data['check_date']; ?></td>
<td><?php echo $data['actual_date']; ?></td>
<td><?php if ($data['score']) echo $data['score']."/100"; ?></td>
<td><?php echo $takecertificatedate; ?></td>
<td><?php echo $licensedate; ?></td>
<td><?php echo $company; ?></td>
<td><?php echo $maintainance_arr[$maintainance]; ?></td>
<td><?php echo $facility_kind; ?></td>
<td><?php echo $account_arr[$repairerid]; ?></td>
<!--<td><?php echo $data['creater']; ?></td>-->
<td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth&2) { ?>
<td>
<p>
<a href="schedule_check-edit.php?id=<?php echo $data['id']; ?>&function_name=schedule_check&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
</td>
<td>
<p>
<a href="schedule_check-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-info btn-sm" onClick="return confirm('Are you sure you want to delete?')">
<span class="glyphicon glyphicon-remove"></span>
</a>
</p>
</td>
<?php } ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
} else {
echo "<h2>There is no record!</h2>";
}
#代表結束連線
mysqli_close($link);
include "footer.php";
?>