channel.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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="channel_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="channel_name">渠道名称</a> </li>
  22. <li> <a tabindex="-1" href="javascript:void(0)" data-field="channel_leader">负责人</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. <a class="btn btn-primary m-r-5" href="addChannel.php"><i class="mdi mdi-plus"></i> 新增渠道</a>
  30. </div>
  31. </div>
  32. <div class="card-body">
  33. <div class="table-responsive">
  34. <form name="form1" id="form1" method="post" action="controller/deleteall.php">
  35. <table class="table table-bordered">
  36. <?php
  37. include_once("../untils/conn.php");
  38. mysqli_query($con, "set names utf8");
  39. if ($con) {
  40. if ($db) {
  41. // 获取搜索关键字
  42. $keyword = isset($_GET['keyword']) ? $_GET['keyword'] : '';
  43. // 构建查询条件
  44. $searchField = isset($_GET['search']) ? $_GET['search'] : 'channel_name';
  45. $whereClause = '';
  46. if (!empty($keyword)) {
  47. $keyword = mysqli_real_escape_string($con, $keyword);
  48. $whereClause = "WHERE $searchField LIKE '%$keyword%'";
  49. }
  50. // 获取数据总行数
  51. $sql = "SELECT * FROM channel $whereClause";
  52. $data = mysqli_query($con, $sql);
  53. $maxrows = mysqli_num_rows($data);
  54. // 计算总页数
  55. $page_size = 10; // 每页显示数
  56. if ($maxrows % $page_size == 0) {
  57. $maxpage = (int)($maxrows / $page_size);
  58. } else {
  59. $maxpage = (int)($maxrows / $page_size) + 1;
  60. }
  61. // 获取当前页
  62. if (isset($_GET['curpage'])) {
  63. $page = $_GET['curpage'];
  64. } else {
  65. $page = 1;
  66. }
  67. // 分段取出数据
  68. $start = $page_size * ($page - 1);
  69. $get_sql = "SELECT * FROM channel $whereClause LIMIT $start,$page_size";
  70. // 得到数据显示
  71. $data = mysqli_query($con, $get_sql);
  72. $sqlyys = "SELECT * FROM `sort` ORDER BY `sortid` DESC LIMIT 1";
  73. $yysdata = mysqli_query($con, $sqlyys);
  74. $yys = mysqli_fetch_row($yysdata);
  75. $index = $yys[1];
  76. ?>
  77. <thead>
  78. <tr>
  79. <th>渠道ID</th>
  80. <th>渠道名称</th>
  81. <th>渠道类型</th>
  82. <th>负责人</th>
  83. <th>电话</th>
  84. <th>创建时间</th>
  85. <th>操作</th>
  86. </tr>
  87. </thead>
  88. <tbody>
  89. <?php
  90. while ($row = mysqli_fetch_array($data)) {
  91. ?>
  92. <tr>
  93. <td style="width:5%;">
  94. <?php echo $row["channel_id"] ?>
  95. </td>
  96. <td style="width:5%;">
  97. <?php echo $row["channel_name"] ?>
  98. </td>
  99. <td style="width:7.5%;">
  100. <?php
  101. switch ($row["channel_type"]) {
  102. case 0:
  103. echo "线上渠道";
  104. break;
  105. case 1:
  106. echo "线下渠道";
  107. break;
  108. }
  109. ?>
  110. </td>
  111. </td>
  112. <td style="width:10%;"><?php echo $row["channel_leader"] ?>
  113. </td>
  114. <td style="width:10%;"><?php echo $row["channel_phone"] ?>
  115. </td>
  116. <td style="width:7.5%;">
  117. <?php
  118. $timestamp= $row["channel_ctime"] ;
  119. $date = date('Y-m-d H:i:s', $timestamp);
  120. echo $date; // 输出:2021-07-22 16:52:07
  121. ?>
  122. </td>
  123. <td style="width:15%;">
  124. <a href="../channel.php?yys=<?php echo $index ?>&channel_id=<?php echo $row['channel_id'] ?> "class="btn .btn-warning btn-sm" target="_blank" >渠道主页</a>
  125. <a href="channellist.php?channel_id=<?php echo $row['channel_id'] ?> "class="btn btn-primary btn-sm" >渠道商品</a>
  126. <a href="channeloder.php?channel_id=<?php echo $row['channel_id'] ?>" class="btn btn-info btn-sm">渠道订单</a>
  127. <a href="upChannel.php?channel_id=<?php echo $row['channel_id'] ?> " class="btn btn-success btn-sm">修改</a>
  128. <a href="controller/deletechannel.php?channel_id=<?php echo $row['channel_id'] ?>" onclick=" return del()" class="btn btn-danger btn-sm">删除</a>
  129. </td>
  130. </tr>
  131. <?php
  132. }
  133. ?>
  134. </tbody>
  135. <tfoot>
  136. <tr>
  137. <td colspan="12" style="text-align: right;">
  138. <?php
  139. echo "<p>共 $maxpage 页&nbsp;&nbsp;";
  140. echo "每页 $page_size 项&nbsp;&nbsp;";
  141. //设置上一页
  142. if ($page > 1) {
  143. $prepage = $page - 1;
  144. echo "<a href='?curpage=$prepage'>上一页</a>&nbsp;&nbsp;";
  145. }
  146. //设置下一页
  147. if ($page < $maxpage) {
  148. $nextpage = $page + 1;
  149. echo "<a href='?curpage=$nextpage'>下一页</a>&nbsp;&nbsp;";
  150. }
  151. echo "&nbsp;&nbsp;第 $page 页</p>";
  152. }
  153. }
  154. ?>
  155. </td>
  156. </tr>
  157. </tfoot>
  158. </table>
  159. </form>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. </main>
  168. <script src="../merchant/assets/js/jquery.min.js"></script>
  169. <script>
  170. $(document).ready(function() {
  171. $('.dropdown-menu a').click(function(e) {
  172. e.preventDefault();
  173. var field = $(this).data('field');
  174. var buttonText = $(this).text();
  175. $('#search').val(field);
  176. $('#search-btn').html(buttonText + ' <span class="caret"></span>');
  177. });
  178. });
  179. </script>
  180. <!--End 页面主要内容-->
  181. <?php require_once('common/footer.php'); ?>
  182. <?php
  183. } else {
  184. echo "<script>alert('您尚未登录,没有权限访问该页面');location.href='login.php';</script>";
  185. }