poster.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <?php
  2. session_start();
  3. if (isset($_SESSION["username"])) {
  4. ?>
  5. <?php require_once('common/header.php'); ?>
  6. <!--页面主要内容-->
  7. <main class="lyear-layout-content">
  8. <div class="container-fluid">
  9. <div class="row">
  10. <div class="col-lg-12">
  11. <div class="card">
  12. <div class="card-toolbar clearfix">
  13. <form class="pull-right search-bar" method="get" action="" role="form">
  14. <div class="input-group">
  15. <div class="input-group-btn">
  16. <input type="hidden" name="search" id="search" value="poster_name">
  17. <button class="btn btn-default dropdown-toggle" id="search-btn" data-toggle="dropdown" type="button" aria-haspopup="true" aria-expanded="false">
  18. 海报名称 <span class="caret"></span>
  19. </button>
  20. <ul class="dropdown-menu">
  21. <li> <a tabindex="-1" href="javascript:void(0)" data-field="poster_name">海报名称</a> </li>
  22. <li> <a tabindex="-1" href="javascript:void(0)" data-field="poster_bz">备注说明</a> </li>
  23. </ul>
  24. </div>
  25. <input type="text" class="form-control" value="" name="keyword" placeholder="请输入查询信息">
  26. </div>
  27. </form>
  28. <div class="toolbar-btn-action">
  29. <!--弹窗开始-->
  30. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo"><i class="mdi mdi-plus"></i>添加海报</button>
  31. <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
  32. <div class="modal-dialog" role="document">
  33. <div class="modal-content">
  34. <div class="modal-header">
  35. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  36. <h4 class="modal-title" id="exampleModalLabel">添加海报</h4>
  37. </div>
  38. <div class="modal-body">
  39. <form action="controller/doAddhb.php" method="post" enctype="multipart/form-data">
  40. <div class="form-group">
  41. <label for="poster_name" class="control-label">海报名称:</label>
  42. <input type="text" class="form-control" id="poster_name" name="poster_name" placeholder="海报名称" required>
  43. </div>
  44. <div class="form-group">
  45. <label for="poster_url" class="control-label">海报图片:</label>
  46. <input type="file" class="form-control" id="poster_url" name="poster_url" placeholder="海报图片" required>
  47. </div>
  48. <div class="form-group">
  49. <label for="poster_bz" class="control-label">备注说明:</label>
  50. <input type="text" class="form-control" id="poster_bz" name="poster_bz" placeholder="备注说明" >
  51. </div>
  52. <!--时间戳-->
  53. <input type="hidden" name="cr_time" value="<?php echo time(); ?>">
  54. </div>
  55. <div class="modal-footer">
  56. <button type="submit" class="btn btn-primary">提交</button>
  57. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  58. </div>
  59. </form>
  60. </div>
  61. </div>
  62. </div>
  63. <!--这是弹窗结束-->
  64. </div>
  65. </div>
  66. <div class="card-body">
  67. <div class="table-responsive">
  68. <form name="form1" id="form1" method="post" action="controller/doUPhb.php">
  69. <table class="table table-bordered">
  70. <?php
  71. include_once("../untils/conn.php");
  72. mysqli_query($con, "set names utf8");
  73. if ($con) {
  74. if ($db) {
  75. // 获取搜索关键词和字段
  76. $keyword = $_GET['keyword'];
  77. $field = $_GET['search'];
  78. // 构建查询语句
  79. $sql = "SELECT * FROM poster";
  80. if ($keyword != "") {
  81. $sql .= " WHERE $field LIKE '%$keyword%'";
  82. }
  83. // 获取数据总行数
  84. $data = mysqli_query($con, $sql);
  85. $maxrows = mysqli_num_rows($data);
  86. // 计算总页数
  87. $page_size = 10; // 每页显示数
  88. if ($maxrows % $page_size == 0) {
  89. $maxpage = (int)($maxrows / $page_size);
  90. } else {
  91. $maxpage = (int)($maxrows / $page_size) + 1;
  92. }
  93. // 获取当前页
  94. if (isset($_GET['curpage'])) {
  95. $page = $_GET['curpage'];
  96. } else {
  97. $page = 1;
  98. }
  99. // 分段取出数据
  100. $start = $page_size * ($page - 1);
  101. $get_sql = "$sql ORDER BY id DESC LIMIT $start, $page_size";
  102. // 获取数据显示
  103. $data = mysqli_query($con, $get_sql);
  104. ?>
  105. <thead>
  106. <tr>
  107. <th>ID</th>
  108. <th>海报名称</th>
  109. <th>海报缩略图</th>
  110. <th>备注说明</th>
  111. <th>创建时间</th>
  112. <th>操作</th>
  113. </tr>
  114. </thead>
  115. <tbody>
  116. <?php
  117. while ($row = mysqli_fetch_array($data)) {
  118. ?>
  119. <tr>
  120. <td style="width:1%;">
  121. <?php echo $row["id"] ?>
  122. </td>
  123. <td style="width:10%;"><?php echo $row["poster_name"] ?>
  124. </td>
  125. <td style="width:5%;" onclick="showPreview('<?php echo $row["poster_url"] ?>')" data-toggle="modal" data-target="#hbModal">
  126. <img src="<?php echo $row["poster_url"] ?>" alt="" style="width:60px; height:60px;">
  127. </td>
  128. <td style="width:5%;"><?php echo $row["poster_bz"] ?>
  129. </td>
  130. <td style="width:5%;">
  131. <?php
  132. $date = date('Y-m-d H:i:s', $row["cr_time"]);
  133. echo $date;
  134. ?>
  135. </td>
  136. <td style="width:15%;">
  137. <button type="button" class="btn btn-info btn-sm" onclick="showPreview('<?php echo $row["poster_url"] ?>')" data-toggle="modal" data-target="#hbModal">
  138. 预览
  139. </button>
  140. <!--<a href="#" class="btn btn-success btn-sm" data-toggle="modal" data-target="#xghbModal" data-whatever="@mdo">修改</a>-->
  141. <a href="controller/deletehb.php?id=<?php echo $row['id'] ?>" onclick="return del()" class="btn btn-danger btn-sm">删除</a>
  142. </td>
  143. </tr>
  144. <?php
  145. }
  146. ?>
  147. </tbody>
  148. <tfoot>
  149. <tr>
  150. <td colspan="12" style="text-align: right;">
  151. <?php
  152. echo "<p>共 $maxpage 页&nbsp;&nbsp;";
  153. echo "每页 $page_size 项&nbsp;&nbsp;";
  154. //设置上一页
  155. if ($page > 1) {
  156. $prepage = $page - 1;
  157. echo "<a href='?curpage=$prepage'>上一页</a>&nbsp;&nbsp;";
  158. }
  159. //设置下一页
  160. if ($page < $maxpage) {
  161. $nextpage = $page + 1;
  162. echo "<a href='?curpage=$nextpage'>下一页</a>&nbsp;&nbsp;";
  163. }
  164. echo "&nbsp;&nbsp;第 $page 页</p>";
  165. }
  166. }
  167. ?>
  168. </td>
  169. </tr>
  170. </tfoot>
  171. </table>
  172. </form>
  173. </div>
  174. </div>
  175. </div>
  176. </div>
  177. </div>
  178. </div>
  179. </div>
  180. <!--预览模拟态-->
  181. <div class="modal fade" id="hbModal" tabindex="-1" role="dialog" aria-labelledby="hbModalLabel">
  182. <div class="modal-dialog" role="document">
  183. <div class="modal-content">
  184. <div class="modal-header">
  185. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  186. <h4 class="modal-title" id="myModalLabel">预览海报</h4>
  187. </div>
  188. <div class="modal-body" style= " display: flex;justify-content: center;align-items: center;">
  189. <img id="posterImage" src="" alt="" >
  190. <!--style="width:360px; height:760px; "-->
  191. </div>
  192. <div class="modal-footer">
  193. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  194. </div>
  195. </div>
  196. </div>
  197. </div>
  198. <!--结束-->
  199. </main>
  200. <script src="../merchant/assets/js/jquery.min.js"></script>
  201. <script>
  202. $(document).ready(function() {
  203. $('.dropdown-menu a').click(function(e) {
  204. e.preventDefault();
  205. var field = $(this).data('field');
  206. var buttonText = $(this).text();
  207. $('#search').val(field);
  208. $('#search-btn').html(buttonText + ' <span class="caret"></span>');
  209. });
  210. });
  211. function showPoster(posterUrl) {
  212. var posterImage = document.getElementById('posterImage');
  213. posterImage.src = posterUrl;
  214. }
  215. function showPreview(posterUrl) {
  216. showPoster(posterUrl);
  217. }
  218. </script>
  219. <!--End 页面主要内容-->
  220. <?php require_once('common/footer.php'); ?>
  221. <?php
  222. } else {
  223. echo "<script>alert('您尚未登录,没有权限访问该页面');location.href='login.php';</script>";
  224. }