teamSeas.php 13 KB

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