teamSeas.php 13 KB

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