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.
 
 
 
 
 
 

289 lines
12 KiB

<?php
include "header.php";
$tourl = $_SERVER["SCRIPT_NAME"] . "?function_name=schedule&token=" . $token;
// 工務總處可瀏覽全部資料
$sql = "select department_id, role_id from account where accountid = '$user_id'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$user_department_id = $row[0];
$user_role_id = $row[1];
mysqli_free_result($res);
// 各區工務助理專員可瀏覽全部
$dr_arr = ['3114', '3133', '3144', '3152'];
if (!isset($_GET["p"]) || $_GET["p"] <= 0) $p = 1;
else $p = $_GET["p"];
$page_each = 50;
$page_from = ($p - 1) * $page_each;
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$page_close = 0;
$sql_cmd2 = "";
$sql_cmd = sql_myself($user_id, "repairedid");
if ($user_department_id == "501" || $user_department_id == "322" || $user_id == "M0012" || $user_id == "M0105") $sql_cmd = "";
if (in_array($user_department_id . $user_role_id, $dr_arr)) $sql_cmd = "";
//if (empty($sql_cmd)) $sql_cmd = "where ";
if (!empty($_GET["contractno"])) $sql_cmd2 .= "and contractno = '" . $_GET["contractno"] . "' ";
if (!empty($_GET["facilityno"])) $sql_cmd2 .= "and facilityno = '" . $_GET["facilityno"] . "' ";
//if (!empty($_GET["repairername"])) $sql_cmd2 .= "and repairername = '".$_GET["repairername"]."' ";
if (!empty($sql_cmd2)) {
if ($sql_cmd == "") $sql_cmd = "where " . ltrim($sql_cmd2, "and");
else $sql_cmd .= $sql_cmd2;
$page_close = 1; // 不分頁
}
//$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id";
$sql = "SELECT * FROM schedule $sql_cmd ORDER BY id asc";
if (!$page_close) $sql .= " limit $page_from, $page_each";
//echo $sql;
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link, $sql);
$total_nums = mysqli_affected_rows($link);
?>
<!-- <a href="create.php"><h2>新增</h2></a> -->
<?php if ($user_auth & 2) { ?>
<p>
<a href="schedule-create.php?function_name=schedule&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
<?php
}
if ($data) :
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])) {
echo "<p class='error'>Please fill up the required field!</p>";
} else {
header("Location:schedule-index.php");
}
}
?>
<style>
table {
table-layout: fixed;
width: 100%;
}
td {
word-wrap: break-word;
}
img {
width: 125px;
}
.width_style_1 {
width: 125px;
}
table {
width: 100%;
}
#table_index2_filter {
float: right;
}
#table_index2_paginate {
float: right;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
}
#preloader {
/* 這是整個會蓋住畫面的底色色塊 */
position: fixed;
width: 100%;
height: 100%;
left: 0%;
top: 10%;
background-color: #fff;
z-index: 9999;
}
#status {
/* 這是中間loading的gif坐標css,我們盡量讓他畫面置中 */
position: fixed;
width: 218px;
height: 419px;
margin-left: -140px;
margin-top: -160px;
left: 50%;
top: 50%;
}
</style>
<script>
$(function() {
$('#table_index2').DataTable({
"pageLength": 50,
"searching": false,
"paging": false,
});
$('.dataTables_length').hide();
//$('.pagination').eq(0).hide();
<?php if (!$page_close) { ?>
$('.dataTables_info').hide();
<?php } ?>
});
</script>
<div style="overflow-x:auto;">
<form method='get' action='<?php echo $tourl; ?>'>
<table class='table table-striped table-bordered' style='width:70%;text-align:center;margin:0 auto'>
<tbody>
<tr>
<th style="text-align:center;vertical-align:middle;">合約號</th>
<td><input type="text" class="form-control" name="contractno" value="<?php if (isset($_GET["contractno"])) echo $_GET["contractno"]; ?>"></td>
<th style="text-align:center;vertical-align:middle;">作番號</th>
<td><input type="text" class="form-control" name="facilityno" value="<?php if (isset($_GET["facilityno"])) echo $_GET["facilityno"]; ?>"></td>
<!--<th>保養員姓名</th>
<td><input type="text" class="form-control" name="repairername" value="<?php if (isset($_GET["repairername"])) echo $_GET["repairername"]; ?>"></td>
-->
<td style="text-align:center;vertical-align:middle;width:80px"><button type="submit" style='text-align:center; margin:0 auto' class="btn btn-info btn-sm">查詢</button></td>
</tr>
</tbody>
</table>
<input type="hidden" name="function_name" value="schedule_index">
<input type="hidden" name="token" value="<?php echo $token; ?>">
</form><br>
<table id="table_index2" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>項次</th>
<th>合約號</th>
<th>作番號</th>
<th>保養套餐編號</th>
<th>保養人員工號</th>
<th>保養人員姓名</th>
<th>應保養日期</th>
<th>實際保養日期</th>
<th>保養項目編號</th>
<th>保養項目內容</th>
<th>保養結果</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) : ?>
<tr>
<td><?php echo $data['id']; ?></td>
<td style="width:100pd;word-break: break-all;"><?php echo $data['contractno']; ?></td>
<td><a href="/app/app-maintenance-uploadsuccess-photo-review.php?id_schedule=<?php echo $data['id']; ?>&<?php echo $token_link; ?>"><?php echo $data['facilityno']; ?></a></td>
<td><?php echo $data['combono']; ?></td>
<td><?php echo $data['repairerid']; ?></td>
<td><?php echo $data['repairername']; ?></td>
<td><?php echo $data['duedate']; ?></td>
<td><?php echo $data['actualdate']; ?></td>
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['item']; ?></td>
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['item_detail']; ?></td>
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['result']; ?></td>
<td><?php if ($data['evidences']) {
echo "<a href=\"/app/" . $data['evidences'] . "\">瀏覽</a>";
} ?></td>
<td><?php echo $data['descriptons']; ?></td>
<td><?php echo $data['customer_login_id']; ?></td>
<td><?php echo $data['customer_login_name']; ?></td>
<td>
<?php
$stars_1 = ($data['stars_c1']) ? $data['stars_c1'] : $data['stars'];
echo $stars_1;
?>
</td>
<td>
<?php
$stars_2 = ($data['stars_c2']) ? $data['stars_c2'] : $data['stars_b2'];
echo $stars_2;
?>
</td>
<td><?php echo $data['details']; ?></td>
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><?php echo $data['customer_signature']; ?></td>
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<?php if ($user_auth & 2) { ?>
<td>
<p>
<a href="schedule-edit.php?id=<?php echo $data['id']; ?>&function_name=schedule&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-pencil"></span>
</a>
</p>
</td>
<td>
<p>
<a href="schedule-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
if (!$page_close) {
if (isset($_GET["contractno"])) $tourl .= "&contractno=" . $_GET["contractno"];
if (isset($_GET["facilityno"])) $tourl .= "&facilityno=" . $_GET["facilityno"];
?>
<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item"><a class="page-link" href="<?php echo $tourl; ?>&p=<?php echo $p - 1; ?>">Previous</a></li>
<?php if ($p > 2) { ?>
<li class="page-item<?php if ($_GET["p"] == ($p - 2)) echo " active"; ?>"><a class="page-link" href="<?php echo $tourl; ?>&p=<?php echo $p - 2; ?>"><?php echo $p - 2; ?></a></li>
<li class="page-item<?php if ($_GET["p"] == ($p - 1)) echo " active"; ?>"><a class="page-link" href="<?php echo $tourl; ?>&p=<?php echo $p - 1; ?>"><?php echo $p - 1; ?></a></li>
<?php } ?>
<li class="page-item<?php if (empty($_GET["p"]) || $_GET["p"] == $p) echo " active"; ?>"><a class="page-link" href="<?php echo $tourl; ?>&p=<?php echo $p; ?>"><?php echo $p; ?></a></li>
<li class="page-item<?php if ($_GET["p"] == ($p + 1)) echo " active"; ?>"><a class="page-link" href="<?php echo $tourl; ?>&p=<?php echo $p + 1; ?>"><?php echo $p + 1; ?></a></li>
<li class="page-item<?php if ($_GET["p"] == ($p + 2)) echo " active"; ?>"><a class="page-link" href="<?php echo $tourl; ?>&p=<?php echo $p + 2; ?>"><?php echo $p + 2; ?></a></li>
<li class="page-item"><a class="page-link" href="<?php echo $tourl; ?>&p=<?php echo $p + 1; ?>">Next</a></li>
</ul>
</nav>
<?php
}
?>
<?php
else :
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
?>