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
5.7 KiB

<?php
include "header.php";
// 設置一個空陣列來放資料
$data = array();
// sql語法存在變數中
$sql = "select * from board where status = 'Y' order by id";
// 用mysqli_query方法執行(sql語法)將結果存在變數中
$data = mysqli_query($link, $sql);
$data2 = $data;
?>
<!-- <a href="create.php"><h2>新增</h2></a> -->
<?php if ($user_auth & 2) { ?>
<p>
<a href="board-create.php?function_name=board&<?php echo $token_link; ?>" class="btn btn-info btn-sm">
<span class="glyphicon glyphicon-plus"></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%;
}
#table_index_filter {
float: right;
}
#table_index_paginate {
float: right;
}
label {
display: inline-flex;
margin-bottom: .5rem;
margin-top: .5rem;
}
/* The Modal (background) */
.modal {
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
z-index: 1;
/* Sit on top */
padding-top: 100px;
/* Location of the box */
left: 0;
top: 0;
width: 100%;
/* Full width */
height: 100%;
/* Full height */
overflow: auto;
/* Enable scroll if needed */
}
.modal .back {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.4);
/* Black w/ opacity */
}
/* Modal Content */
.modal-content {
z-index: 9;
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
/* The Close Button */
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
</style>
<div style="overflow-x:auto;">
<table id="table_index" 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>
</tr>
</thead>
<tbody>
<?php foreach ($data as $data) : ?>
<tr>
<td><?php echo $data['id']; ?></td>
<!-- <td><?php echo $data['title']; ?></td> -->
<td><a onclick="openModal('<?php echo $data['id']; ?>')" href="#"><?php echo $data['title']; ?></button></a>
<td><a href="/wms/board-file.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" target="_blank"><?php echo str_replace("board-attach/", "", $data['attach']); ?></a></td>
<!--<td><?php if ($data['pin'] > 1) echo "是";
else echo "否"; ?></td>-->
<td><?php echo $data['creater']; ?></td>
<td><?php echo $data['create_at']; ?></td>
<td>
<p>
<?php if (($data['creater'] == $user_id) && ($data['status'] == "Y")) { ?>
<a href="board-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-info btn-sm" onClick="return confirm('確認關閉公告嗎?')">
<span class="glyphicon glyphicon-remove"></span>
</a>
<?php } else echo "-"; ?>
</p>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
foreach ($data2 as $data2) :
?>
<div id="myModal<?php echo $data2['id']; ?>" class="modal">
<div class="back"></div>
<div class="modal-content">
<button type="button" class="close myCloseBtn" id="">X</button>
<div class='col-12' style='text-align:center'>
<h3><?php echo $data2['title']; ?></h3>
<br/>
<?php echo nl2br($data2['content']); ?>
</div>
</div>
</div>
<?php endforeach; ?>
<script>
var modal = document.getElementById("myModal");
function openModal(id) {
$("#myModal" + id).show();
}
$(".myCloseBtn").click(function(e) {
$(".modal").hide();
});
$(".back").click(function(e) {
$(".modal").hide();
});
</script>
<?php
else :
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "footer.php";
?>