teamSeas.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <?php
  2. require_once 'conn.php';
  3. checkLogin();
  4. $act = $_GET['act'] ?? '';
  5. $keys = $_GET['Keys'] ?? '';
  6. $keyscode = textEncode($keys);
  7. $page = $_GET['Page'] ?? '';
  8. $filterCountry = $_GET['fliterCountry'] ?? '';
  9. $filterQudao = $_GET['fliterQudao'] ?? '';
  10. $filterDeal = $_GET['fliterDeal'] ?? '';
  11. $filterBusiness = $_GET['fliterBusiness'] ?? '';
  12. $filterBelong = $_GET['fliterBelong'] ?? '';
  13. $filterStr = "";
  14. $urlStr = "";
  15. if (!empty($filterCountry)) {
  16. $filterStr .= " AND cs_country=" . (int)$filterCountry;
  17. $urlStr .= "&fliterCountry=" . $filterCountry;
  18. }
  19. if (!empty($filterQudao)) {
  20. $filterStr .= " AND cs_from=" . (int)$filterQudao;
  21. $urlStr .= "&fliterQudao=" . $filterQudao;
  22. }
  23. if (!empty($filterDeal)) {
  24. $filterStr .= " AND cs_deal=" . (int)$filterDeal;
  25. $urlStr .= "&fliterDeal=" . $filterDeal;
  26. }
  27. if (!empty($filterBusiness)) {
  28. $filterStr .= " AND cs_type=" . (int)$filterBusiness;
  29. $urlStr .= "&fliterBusiness=" . $filterBusiness;
  30. }
  31. if (!empty($filterBelong)) {
  32. $filterStr .= " AND cs_belong=" . (int)$filterBelong;
  33. $urlStr .= "&fliterBelong=" . $filterBelong;
  34. }
  35. $keys = urlencode($keys);
  36. $hrefstr = "?keys=" . $keys;
  37. if ($_SESSION['em_role'] == 0) {
  38. $memberStr = "SELECT id FROM employee WHERE em_role=" . $_SESSION['employee_id'] . " OR id=" . $_SESSION['employee_id'];
  39. } else {
  40. $memberStr = "SELECT id FROM employee WHERE em_role=" . $_SESSION['em_role'] . " OR id=" . $_SESSION['em_role'];
  41. }
  42. ?>
  43. <!DOCTYPE html>
  44. <html xmlns="http://www.w3.org/1999/xhtml">
  45. <head>
  46. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  47. <title>管理区域</title>
  48. <link rel="stylesheet" href="css/common.css" type="text/css" />
  49. <link rel="stylesheet" href="css/alert.css" type="text/css" />
  50. <script src="system/js/jquery-1.7.2.min.js"></script>
  51. <script src="js/js.js?ver=0620"></script>
  52. <style>
  53. body {
  54. margin: 0;
  55. padding: 20px;
  56. background: #fff;
  57. }
  58. #man_zone {
  59. margin-left: 0;
  60. }
  61. </style>
  62. </head>
  63. <body class="clear">
  64. <?php // require_once 'panel.php'; ?>
  65. <div id="man_zone">
  66. <form id="form1" method="post" action="?act=postchk&Keys=<?= $keys ?>&Page=<?= $page ?>" onSubmit="return false">
  67. <div class="fastSelect clear">
  68. <H1>搜索条件</H1>
  69. <div class="selectItem">
  70. <label>区域</label>
  71. <select name="fliterCountry" class="filterSearch">
  72. <option value="">请选择国家地区</option>
  73. <?php
  74. $result = $conn->query("SELECT id, countryName FROM country");
  75. while ($row = $result->fetch_assoc()) {
  76. $selected = ($filterCountry == $row['id']) ? ' selected="selected"' : '';
  77. echo "<option value=\"{$row['id']}\"{$selected}>" . htmlspecialchars($row['countryName']) . "</option>";
  78. }
  79. ?>
  80. </select>
  81. </div>
  82. <div class="selectItem">
  83. <label>来源渠道</label>
  84. <select name="fliterQudao" class="filterSearch">
  85. <option value="">请选择渠道</option>
  86. <?php
  87. $result = $conn->query("SELECT id, ch_name FROM qudao");
  88. while ($row = $result->fetch_assoc()) {
  89. $selected = ($filterQudao == $row['id']) ? ' selected="selected"' : '';
  90. echo "<option value=\"{$row['id']}\"{$selected}>" . htmlspecialchars($row['ch_name']) . "</option>";
  91. }
  92. ?>
  93. </select>
  94. </div>
  95. <div class="selectItem">
  96. <label>跟进阶段</label>
  97. <select name="fliterDeal" class="filterSearch">
  98. <option value="">请选择</option>
  99. <option value="0"<?= ($filterDeal == "0") ? ' selected="selected"' : '' ?>>无响应</option>
  100. <option value="1"<?= ($filterDeal == "1") ? ' selected="selected"' : '' ?>>背景调查</option>
  101. <option value="2"<?= ($filterDeal == "2") ? ' selected="selected"' : '' ?>>明确需求</option>
  102. </select>
  103. </div>
  104. <div class="selectItem">
  105. <label>客户类型</label>
  106. <select name="fliterBusiness" class="filterSearch">
  107. <option value="">请选择</option>
  108. <?php
  109. $result = $conn->query("SELECT id, businessType FROM clientType");
  110. while ($row = $result->fetch_assoc()) {
  111. $selected = ($filterBusiness == $row['id']) ? ' selected="selected"' : '';
  112. echo "<option value=\"{$row['id']}\"{$selected}>" . htmlspecialchars($row['businessType']) . "</option>";
  113. }
  114. ?>
  115. </select>
  116. </div>
  117. <div class="selectItem">
  118. <label>业务员</label>
  119. <select name="fliterBelong" class="filterSearch">
  120. <option value="">请选择</option>
  121. <?php
  122. $result = $conn->query("SELECT id, em_user FROM employee WHERE id IN (" . $memberStr . ")");
  123. while ($row = $result->fetch_assoc()) {
  124. $selected = ($filterBelong == $row['id']) ? ' selected="selected"' : '';
  125. echo "<option value=\"{$row['id']}\"{$selected}>" . htmlspecialchars($row['em_user']) . "</option>";
  126. }
  127. ?>
  128. </select>
  129. </div>
  130. </div>
  131. <div width="100%" border="0" cellpadding="3" cellspacing="1" class="table2">
  132. <div class="theader">
  133. <div class="col9">序号</div>
  134. <div class="col3">客户编号</div>
  135. <div class="col4">渠道来源</div>
  136. <div class="col5">区域</div>
  137. <div class="col6">客户类型</div>
  138. <div class="col6">是否成交</div>
  139. <div class="col20">更新日期</div>
  140. <div class="col4">操作</div>
  141. </div>
  142. <?php
  143. $sqlStr = "SELECT * FROM customer
  144. WHERE cs_deal<>3 AND cs_type<>2
  145. AND DATEDIFF(NOW(), cs_updatetime) > 60
  146. AND cs_wechat NOT LIKE 'wxid%'
  147. AND cs_belongclient=0
  148. AND cs_belong<>" . $_SESSION['employee_id'] . "
  149. AND cs_belong IN (" . $memberStr . ")
  150. AND (cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  151. OR cs_name LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  152. OR cs_email LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  153. OR cs_wechat LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  154. OR cs_tel LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  155. OR cs_whatsapp LIKE '%" . $conn->real_escape_string($keyscode) . "%')" .
  156. $filterStr . " ORDER BY cs_state DESC, id DESC";
  157. $result = $conn->query($sqlStr);
  158. if ($result && $result->num_rows > 0) {
  159. $pageSize = 20;
  160. $page = empty($page) ? 1 : $page;
  161. $page = ($page === 'end') ? ceil($result->num_rows / $pageSize) : $page;
  162. $page = (!is_numeric($page) || $page < 1) ? 1 : (int)$page;
  163. $totalPages = ceil($result->num_rows / $pageSize);
  164. $page = ($page > $totalPages) ? $totalPages : $page;
  165. $offset = $pageSize * ($page - 1);
  166. $rows = [];
  167. while ($row = $result->fetch_assoc()) {
  168. $rows[] = $row;
  169. }
  170. $paginatedRows = array_slice($rows, $offset, $pageSize);
  171. $tempNum = $offset;
  172. foreach ($paginatedRows as $row) {
  173. $tempNum++;
  174. ?>
  175. <div class="tline">
  176. <div class="col9"><?= $tempNum ?></div>
  177. <div class="col3 slidepanel">
  178. <?= htmlspecialchars($row['cs_code']) ?>
  179. <?php if ($row['cs_claimFrom'] > 0): ?>
  180. <img src="../images/yijiao.png" class="handover">
  181. <?php endif; ?>
  182. </div>
  183. <div class="col4">
  184. <?php
  185. $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
  186. echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialchars($qudaoRow['ch_name']) : '未填写';
  187. ?>
  188. </div>
  189. <div class="col5">
  190. <?php
  191. $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
  192. echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialchars($countryRow['countryName']) : '未填写';
  193. ?>
  194. </div>
  195. <div class="col6">
  196. <?php
  197. $typeResult = $conn->query("SELECT businessType FROM clientType WHERE id=" . (int)$row['cs_type']);
  198. echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialchars($typeRow['businessType']) : '未填写';
  199. ?>
  200. </div>
  201. <div class="col6">
  202. <?php
  203. if ($row['cs_deal'] == 2) {
  204. echo "明确需求";
  205. } elseif ($row['cs_deal'] == 1) {
  206. echo "背景调查";
  207. } else {
  208. echo "未成交";
  209. }
  210. ?>
  211. </div>
  212. <div class="col20"><?= $row['cs_updatetime'] ?></div>
  213. <div class="col4"><span id="claim" class="claim" data-id="<?= $row['id'] ?>">认领</span></div>
  214. </div>
  215. <div class="notepanel clear">
  216. <div class="noteItem2">备注</div>
  217. <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
  218. </div>
  219. <?php
  220. }
  221. } else {
  222. if (empty($keys)) {
  223. ?>
  224. <tr>
  225. <div align="center" colspan="8">Sorry,当前暂无信息</div>
  226. </tr>
  227. <?php
  228. } else {
  229. ?>
  230. <tr>
  231. <div align="center" colspan="8"><a href="?">Sorry,没有找到"<?= htmlspecialchars($keyscode) ?>"相关的信息,点击返回</a></div>
  232. </tr>
  233. <?php
  234. }
  235. }
  236. ?>
  237. <div colspan="8">
  238. <div class="showpagebox">
  239. <?php
  240. if (isset($totalPages) && $totalPages > 1) {
  241. $pageName = "?Keys=" . $keys . $urlStr . "&";
  242. $pagelen = 3;
  243. if ($page > 1) {
  244. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  245. echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
  246. }
  247. if ($pagelen * 2 + 1 >= $totalPages) {
  248. $startPage = 1;
  249. $endPage = $totalPages;
  250. } else {
  251. if ($page <= $pagelen + 1) {
  252. $startPage = 1;
  253. $endPage = $pagelen * 2 + 1;
  254. } else {
  255. $startPage = $page - $pagelen;
  256. $endPage = $page + $pagelen;
  257. }
  258. if ($page + $pagelen > $totalPages) {
  259. $startPage = $totalPages - $pagelen * 2;
  260. $endPage = $totalPages;
  261. }
  262. }
  263. for ($i = $startPage; $i <= $endPage; $i++) {
  264. if ($i == $page) {
  265. echo "<a class=\"current\">{$i}</a>";
  266. } else {
  267. echo "<a href=\"{$pageName}Page={$i}\">{$i}</a>";
  268. }
  269. }
  270. if ($page < $totalPages) {
  271. if ($totalPages - $page > $pagelen) {
  272. echo "<a href=\"{$pageName}Page={$totalPages}\">...{$totalPages}</a>";
  273. }
  274. echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
  275. echo "<a href=\"{$pageName}Page={$totalPages}\">尾页</a>";
  276. }
  277. }
  278. ?>
  279. </div>
  280. </div>
  281. </div>
  282. </form>
  283. </div>
  284. </body>
  285. </html>