teamSeas.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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 c.cs_country=" . (int)$filterCountry;
  17. $urlStr .= "&fliterCountry=" . $filterCountry;
  18. }
  19. if (!empty($filterQudao)) {
  20. $filterStr .= " AND c.cs_from=" . (int)$filterQudao;
  21. $urlStr .= "&fliterQudao=" . $filterQudao;
  22. }
  23. if (!empty($filterDeal)) {
  24. $filterStr .= " AND c.cs_deal=" . (int)$filterDeal;
  25. $urlStr .= "&fliterDeal=" . $filterDeal;
  26. }
  27. if (!empty($filterBusiness)) {
  28. $filterStr .= " AND c.cs_type=" . (int)$filterBusiness;
  29. $urlStr .= "&fliterBusiness=" . $filterBusiness;
  30. }
  31. if (!empty($filterBelong)) {
  32. $filterStr .= " AND c.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 c.*, cc.contact_name as cs_name, cc.tel as cs_tel, cc.email as cs_email,
  145. cc.whatsapp as cs_whatsapp, cc.wechat as cs_wechat, cc.linkedin as cs_linkedin,
  146. cc.facebook as cs_facebook, cc.alibaba as cs_alibaba
  147. FROM customer c
  148. LEFT JOIN customer_contact cc ON c.id = cc.customer_id
  149. WHERE c.cs_deal<>3 AND c.cs_type<>2
  150. AND DATEDIFF(NOW(), c.cs_updatetime) > 60
  151. AND cc.wechat NOT LIKE 'wxid%'
  152. AND c.cs_belongclient=0
  153. AND c.cs_belong<>" . $_SESSION['employee_id'] . "
  154. AND c.cs_belong IN (" . $memberStr . ")
  155. AND (c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  156. OR cc.contact_name LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  157. OR cc.email LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  158. OR cc.wechat LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  159. OR cc.tel LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  160. OR cc.whatsapp LIKE '%" . $conn->real_escape_string($keyscode) . "%')" .
  161. $filterStr . " ORDER BY c.cs_state DESC, c.id DESC";
  162. $result = $conn->query($sqlStr);
  163. if ($result && $result->num_rows > 0) {
  164. $pageSize = 20;
  165. $page = empty($page) ? 1 : $page;
  166. $page = ($page === 'end') ? ceil($result->num_rows / $pageSize) : $page;
  167. $page = (!is_numeric($page) || $page < 1) ? 1 : (int)$page;
  168. $totalPages = ceil($result->num_rows / $pageSize);
  169. $page = ($page > $totalPages) ? $totalPages : $page;
  170. $offset = $pageSize * ($page - 1);
  171. $rows = [];
  172. while ($row = $result->fetch_assoc()) {
  173. $rows[] = $row;
  174. }
  175. $paginatedRows = array_slice($rows, $offset, $pageSize);
  176. $tempNum = $offset;
  177. foreach ($paginatedRows as $row) {
  178. $tempNum++;
  179. ?>
  180. <div class="tline">
  181. <div class="col9"><?= $tempNum ?></div>
  182. <div class="col3 slidepanel">
  183. <?= htmlspecialcharsFix($row['cs_code']) ?>
  184. <?php if ($row['cs_claimFrom'] > 0): ?>
  185. <img src="../images/yijiao.png" class="handover">
  186. <?php endif; ?>
  187. </div>
  188. <div class="col4">
  189. <?php
  190. $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
  191. echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未填写';
  192. ?>
  193. </div>
  194. <div class="col5">
  195. <?php
  196. $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
  197. echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未填写';
  198. ?>
  199. </div>
  200. <div class="col6">
  201. <?php
  202. $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . (int)$row['cs_type']);
  203. echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialcharsFix($typeRow['businessType']) : '未填写';
  204. ?>
  205. </div>
  206. <div class="col6">
  207. <?php
  208. if ($row['cs_deal'] == 2) {
  209. echo "明确需求";
  210. } elseif ($row['cs_deal'] == 1) {
  211. echo "背景调查";
  212. } else {
  213. echo "未成交";
  214. }
  215. ?>
  216. </div>
  217. <div class="col20"><?= $row['cs_updatetime'] ?></div>
  218. <div class="col4"><span id="claim" class="claim" data-id="<?= $row['id'] ?>">认领</span></div>
  219. </div>
  220. <div class="notepanel clear">
  221. <div class="noteItem2">备注</div>
  222. <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
  223. </div>
  224. <?php
  225. }
  226. } else {
  227. if (empty($keys)) {
  228. ?>
  229. <tr>
  230. <div align="center" colspan="8">Sorry,当前暂无信息</div>
  231. </tr>
  232. <?php
  233. } else {
  234. ?>
  235. <tr>
  236. <div align="center" colspan="8"><a href="?">Sorry,没有找到"<?= htmlspecialcharsFix($keyscode) ?>"相关的信息,点击返回</a></div>
  237. </tr>
  238. <?php
  239. }
  240. }
  241. ?>
  242. <div colspan="8">
  243. <div class="showpagebox">
  244. <?php
  245. if (isset($totalPages) && $totalPages > 1) {
  246. $pageName = "?Keys=" . $keys . $urlStr . "&";
  247. $pagelen = 3;
  248. if ($page > 1) {
  249. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  250. echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
  251. }
  252. if ($pagelen * 2 + 1 >= $totalPages) {
  253. $startPage = 1;
  254. $endPage = $totalPages;
  255. } else {
  256. if ($page <= $pagelen + 1) {
  257. $startPage = 1;
  258. $endPage = $pagelen * 2 + 1;
  259. } else {
  260. $startPage = $page - $pagelen;
  261. $endPage = $page + $pagelen;
  262. }
  263. if ($page + $pagelen > $totalPages) {
  264. $startPage = $totalPages - $pagelen * 2;
  265. $endPage = $totalPages;
  266. }
  267. }
  268. for ($i = $startPage; $i <= $endPage; $i++) {
  269. if ($i == $page) {
  270. echo "<a class=\"current\">{$i}</a>";
  271. } else {
  272. echo "<a href=\"{$pageName}Page={$i}\">{$i}</a>";
  273. }
  274. }
  275. if ($page < $totalPages) {
  276. if ($totalPages - $page > $pagelen) {
  277. echo "<a href=\"{$pageName}Page={$totalPages}\">...{$totalPages}</a>";
  278. }
  279. echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
  280. echo "<a href=\"{$pageName}Page={$totalPages}\">尾页</a>";
  281. }
  282. }
  283. ?>
  284. </div>
  285. </div>
  286. </div>
  287. </form>
  288. </div>
  289. </body>
  290. </html>