customers.php 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. <?php
  2. require_once('conn.php');
  3. checkLogin("信息管理");
  4. // Initialize variables
  5. $urlStr = "";
  6. $act = $_GET['act'] ?? '';
  7. $output = '';
  8. // Process all actions that might need headers
  9. if ($act == "save") {
  10. $isEdit = false;
  11. $id = $_POST['id'] ?? '';
  12. if (!empty($id) && is_numeric($id)) {
  13. $isEdit = true;
  14. }
  15. $cs_code = textEncode($_POST['cs_code'] ?? '');
  16. $cs_company = textEncode($_POST['cs_company'] ?? '');
  17. $cs_name = textEncode($_POST['cs_name'] ?? '');
  18. $cs_belong = intval($_POST['cs_belong'] ?? 0);
  19. $cs_country = intval($_POST['cs_country'] ?? 0);
  20. $cs_from = intval($_POST['cs_from'] ?? 0);
  21. $cs_tel = textEncode($_POST['cs_tel'] ?? '');
  22. $cs_email = textEncode($_POST['cs_email'] ?? '');
  23. $cs_whatsapp = textEncode($_POST['cs_whatsapp'] ?? '');
  24. $cs_wechat = textEncode($_POST['cs_wechat'] ?? '');
  25. $cs_linkedin = textEncode($_POST['cs_linkedin'] ?? '');
  26. $cs_facebook = textEncode($_POST['cs_facebook'] ?? '');
  27. $cs_alibaba = textEncode($_POST['cs_alibaba'] ?? '');
  28. $cs_state = intval($_POST['cs_state'] ?? 0);
  29. $cs_deal = intval($_POST['cs_deal'] ?? 0);
  30. $no_content = htmlEncode($_POST['no_content'] ?? '');
  31. $allowedit = isset($_POST['allowedit']) ? 1 : 0;
  32. if ($isEdit) {
  33. $sql = "SELECT cs_chain FROM customer WHERE id=" . $id;
  34. $result = $conn->query($sql);
  35. if ($row = $result->fetch_assoc()) {
  36. $cs_chain = $row['cs_chain'];
  37. $chain_array = explode(',', $cs_chain);
  38. $last_item = end($chain_array);
  39. if ($last_item != $cs_belong) {
  40. $cs_chain .= ",$cs_belong";
  41. }
  42. $sql = "UPDATE customer SET
  43. cs_code='$cs_code',
  44. cs_company='$cs_company',
  45. cs_name='$cs_name',
  46. cs_belong=$cs_belong,
  47. cs_country=$cs_country,
  48. cs_from=$cs_from,
  49. cs_tel='$cs_tel',
  50. cs_email='$cs_email',
  51. cs_whatsapp='$cs_whatsapp',
  52. cs_wechat='$cs_wechat',
  53. cs_linkedin='$cs_linkedin',
  54. cs_facebook='$cs_facebook',
  55. cs_alibaba='$cs_alibaba',
  56. cs_state=$cs_state,
  57. cs_deal=$cs_deal,
  58. cs_note='$no_content',
  59. allowedit=$allowedit,
  60. cs_chain='$cs_chain',
  61. cs_updatetime=NOW()
  62. WHERE id=$id";
  63. $conn->query($sql);
  64. $page = $_GET['Page'] ?? '';
  65. $keys = urlencode($_GET['Keys'] ?? '');
  66. header("Location: ?keys=$keys&Page=$page$urlStr");
  67. exit;
  68. } else {
  69. $output = "<script>alert('不存在该客户');history.back();</script>";
  70. }
  71. } else {
  72. $sql = "INSERT INTO customer (
  73. cs_code, cs_company, cs_name, cs_belong, cs_country, cs_from,
  74. cs_tel, cs_email, cs_whatsapp, cs_wechat, cs_linkedin,
  75. cs_facebook, cs_alibaba, cs_state, cs_deal, cs_note,
  76. allowedit, cs_chain, cs_addtime, cs_updatetime
  77. ) VALUES (
  78. '$cs_code', '$cs_company', '$cs_name', $cs_belong, $cs_country, $cs_from,
  79. '$cs_tel', '$cs_email', '$cs_whatsapp', '$cs_wechat', '$cs_linkedin',
  80. '$cs_facebook', '$cs_alibaba', $cs_state, $cs_deal, '$no_content',
  81. $allowedit, '$cs_belong', NOW(), NOW()
  82. )";
  83. $conn->query($sql);
  84. header("Location: ?");
  85. exit;
  86. }
  87. }
  88. // If we have output from processing, we'll show it instead of the normal page
  89. if (!empty($output)) {
  90. echo $output;
  91. exit;
  92. }
  93. ?>
  94. <!DOCTYPE html>
  95. <html xmlns="http://www.w3.org/1999/xhtml">
  96. <head>
  97. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  98. <title>管理区域</title>
  99. <link rel="stylesheet" href="css/common.css" type="text/css" />
  100. <script language="javascript" src="js/jquery-1.7.2.min.js"></script>
  101. <script type="text/javascript" src="js/js.js"></script>
  102. <script type="text/javascript" src="xheditor-1.1.9/xheditor-1.1.9-zh-cn.min.js"></script>
  103. <script>
  104. $(document).ready(function(){
  105. $('.txt2').xheditor({
  106. tools:'full',
  107. hoverExecDelay:-1,
  108. urlBase:'system/',
  109. upLinkUrl:"upload.php",
  110. upLinkExt:"zip,rar,txt,pdf",
  111. upImgUrl:"upload.php",
  112. upImgExt:"jpg,jpeg,gif,png",
  113. upFlashUrl:"upload.php",
  114. upFlashExt:"swf",
  115. upMediaUrl:"upload.php",
  116. upMediaExt:"wmv,avi,wma,mp3,mid"
  117. });
  118. });
  119. </script>
  120. </head>
  121. <body>
  122. <div id="man_zone">
  123. <?php
  124. // 编辑操作
  125. if ($act == "edit" || $act == "add") {
  126. $id = $_GET['id'] ?? '';
  127. $isEdit = false;
  128. // 初始化变量
  129. $cs_code = $cs_company = $cs_name = $cs_tel = $cs_telBu = '';
  130. $cs_wechat = $cs_wechatBu = $cs_whatsapp = $cs_whatsappBu = '';
  131. $cs_email = $cs_emailBu = $cs_linkedin = $cs_linkedinBu = '';
  132. $cs_facebook = $cs_facebookBu = $cs_alibaba = $cs_alibabaBu = '';
  133. $cs_address = $cs_addtime = $cs_updatetime = $cs_note = '';
  134. $cs_belong = $cs_country = $cs_from = $cs_state = $cs_deal = $allowedit = 0;
  135. if (!empty($id) && is_numeric($id)) {
  136. $isEdit = true;
  137. $sql = "SELECT c.*, n.c_code
  138. FROM customer c
  139. LEFT JOIN mynote n ON c.cs_code = n.c_code
  140. WHERE c.id=$id";
  141. $result = $conn->query($sql);
  142. if ($row = $result->fetch_assoc()) {
  143. $cs_code = textUncode($row['cs_code']);
  144. $cs_company = textUncode($row['cs_company']);
  145. $cs_name = textUncode($row['cs_name']);
  146. $cs_country = $row['cs_country'];
  147. $cs_from = $row['cs_from'];
  148. $cs_tel = textUncode($row['cs_tel']);
  149. $cs_telBu = textUncode($row['cs_telBu']);
  150. $cs_wechat = textUncode($row['cs_wechat']);
  151. $cs_wechatBu = textUncode($row['cs_wechatBu']);
  152. $cs_whatsapp = textUncode($row['cs_whatsapp']);
  153. $cs_whatsappBu = textUncode($row['cs_whatsappBu']);
  154. $cs_email = textUncode($row['cs_email']);
  155. $cs_emailBu = textUncode($row['cs_emailBu']);
  156. $cs_linkedin = textUncode($row['cs_linkedin']);
  157. $cs_linkedinBu = textUncode($row['cs_linkedinBu']);
  158. $cs_facebook = textUncode($row['cs_facebook']);
  159. $cs_facebookBu = textUncode($row['cs_facebookBu']);
  160. $cs_alibaba = textUncode($row['cs_alibaba']);
  161. $cs_alibabaBu = textUncode($row['cs_alibabaBu']);
  162. $cs_address = textUncode($row['cs_address']);
  163. $cs_addtime = $row['cs_addtime'];
  164. $cs_updatetime = $row['cs_updatetime'];
  165. $cs_belong = $row['cs_belong'];
  166. $cs_state = $row['cs_state'];
  167. $cs_deal = $row['cs_deal'];
  168. $cs_note = htmlUncode($row['cs_note']);
  169. $allowedit = $row['allowedit'];
  170. }
  171. }
  172. $page = $_GET['Page'] ?? '';
  173. $keys = urlencode($_GET['Keys'] ?? '');
  174. $ord = urlencode($_GET['Ord'] ?? '');
  175. $hrefstr = "?keys=$keys&Page=$page&Ord=$ord";
  176. ?>
  177. <form name="form1" method="post" action="<?php echo $hrefstr; ?>&act=save">
  178. <table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
  179. <tbody>
  180. <tr>
  181. <th width="8%">客户编号</th>
  182. <td><input type="text" id="cs_code" name="cs_code" value="<?php echo $cs_code; ?>" class="txt1" />
  183. <input type="hidden" name="id" value="<?php echo $id; ?>" /></td>
  184. </tr>
  185. <tr>
  186. <th width="8%">公司名称</th>
  187. <td><input type="text" id="cs_company" name="cs_company" value="<?php echo $cs_company; ?>" class="txt1" /></td>
  188. </tr>
  189. <tr>
  190. <th width="8%">联系人</th>
  191. <td><input type="text" id="cs_name" name="cs_name" value="<?php echo $cs_name; ?>" class="txt1" /></td>
  192. </tr>
  193. <tr>
  194. <th width="8%">所属业务</th>
  195. <td>
  196. <select name="cs_belong">
  197. <option value="0">请选择</option>
  198. <?php
  199. $sql = "SELECT id,em_user FROM employee";
  200. $result = $conn->query($sql);
  201. while($row = $result->fetch_assoc()) {
  202. $selected = ($row['id'] == $cs_belong) ? ' selected="selected"' : '';
  203. echo "<option value=\"{$row['id']}\"$selected>{$row['em_user']}</option>";
  204. }
  205. ?>
  206. </select>
  207. </td>
  208. </tr>
  209. <tr>
  210. <th width="8%">国家</th>
  211. <td>
  212. <select name="cs_country">
  213. <option value="0">请选择</option>
  214. <?php
  215. $sql = "SELECT id,countryCode,countryName FROM country";
  216. $result = $conn->query($sql);
  217. while($row = $result->fetch_assoc()) {
  218. $selected = ($row['id'] == $cs_country) ? ' selected="selected"' : '';
  219. echo "<option value=\"{$row['id']}\"$selected>{$row['countryName']}</option>";
  220. }
  221. ?>
  222. </select>
  223. </td>
  224. </tr>
  225. <tr>
  226. <th width="8%">来源</th>
  227. <td>
  228. <select name="cs_from">
  229. <option value="0">请选择</option>
  230. <?php
  231. $sql = "SELECT id,ch_name FROM qudao";
  232. $result = $conn->query($sql);
  233. while($row = $result->fetch_assoc()) {
  234. $selected = ($row['id'] == $cs_from) ? ' selected="selected"' : '';
  235. echo "<option value=\"{$row['id']}\"$selected>{$row['ch_name']}</option>";
  236. }
  237. ?>
  238. </select>
  239. </td>
  240. </tr>
  241. <tr>
  242. <th width="8%">录入时间</th>
  243. <td><?php echo $cs_addtime; ?></td>
  244. </tr>
  245. <tr>
  246. <th width="8%">更新时间</th>
  247. <td><?php echo $cs_updatetime; ?></td>
  248. </tr>
  249. <tr>
  250. <th width="8%" rowspan="7">联系方式</th>
  251. <td><input type="text" id="cs_tel" name="cs_tel" value="<?php echo $cs_tel ?? ''; ?>" class="txt5 tel" />备份:<?php echo $cs_telBu ?? ''; ?></td>
  252. </tr>
  253. <tr>
  254. <td><input type="text" id="cs_email" name="cs_email" value="<?php echo $cs_email ?? ''; ?>" class="txt5 mail" />备份:<?php echo $cs_emailBu ?? ''; ?></td>
  255. </tr>
  256. <tr>
  257. <td><input type="text" id="cs_whatsapp" name="cs_whatsapp" value="<?php echo $cs_whatsapp ?? ''; ?>" class="txt5 whatsapp" />备份:<?php echo $cs_whatsappBu ?? ''; ?></td>
  258. </tr>
  259. <tr>
  260. <td><input type="text" id="cs_wechat" name="cs_wechat" value="<?php echo $cs_wechat ?? ''; ?>" class="txt5 wechat" />备份:<?php echo $cs_wechatBu ?? ''; ?></td>
  261. </tr>
  262. <tr>
  263. <td><input type="text" id="cs_linkedin" name="cs_linkedin" value="<?php echo $cs_linkedin ?? ''; ?>" class="txt5 linkedin" />备份:<?php echo $cs_linkedinBu ?? ''; ?></td>
  264. </tr>
  265. <tr>
  266. <td><input type="text" id="cs_facebook" name="cs_facebook" value="<?php echo $cs_facebook ?? ''; ?>" class="txt5 facebook" />备份:<?php echo $cs_facebookBu ?? ''; ?></td>
  267. </tr>
  268. <tr>
  269. <td><input type="text" id="cs_alibaba" name="cs_alibaba" value="<?php echo $cs_alibaba ?? ''; ?>" class="txt5 alibaba" />备份:<?php echo $cs_alibabaBu ?? ''; ?></td>
  270. </tr>
  271. <tr>
  272. <th width="8%">地址</th>
  273. <td><input type="text" id="cs_address" name="cs_address" value="<?php echo $cs_address ?? ''; ?>" class="txt1" /></td>
  274. </tr>
  275. <tr>
  276. <th width="8%">标签</th>
  277. <td>
  278. <?php
  279. if($isEdit ?? false) {
  280. $sql = "SELECT id,tagName FROM tagtable WHERE customerId = ?";
  281. $stmt = $conn->prepare($sql);
  282. $stmt->bind_param("i", $id);
  283. $stmt->execute();
  284. $result = $stmt->get_result();
  285. while($row = $result->fetch_assoc()) {
  286. echo htmlspecialchars($row['tagName'] ?? '') . ',';
  287. }
  288. $stmt->close();
  289. }
  290. ?>
  291. </td>
  292. </tr>
  293. <tr>
  294. <th width="8%">状态</th>
  295. <td>
  296. <label><input type="radio" name="cs_state" value="1" <?php if(($cs_state ?? 0)==1) echo 'checked="checked"'; ?> />有效</label>
  297. <label><input type="radio" name="cs_state" value="0" <?php if(($cs_state ?? 0)!=1) echo 'checked="checked"'; ?> />不再跟进</label>
  298. </td>
  299. </tr>
  300. <tr>
  301. <th width="8%">是否误报</th>
  302. <td>
  303. <label><input type="radio" name="allowedit" value="1" <?php if(($allowedit ?? 0)==1) echo 'checked="checked"'; ?> />审核通过</label>
  304. <label><input type="radio" name="allowedit" value="0" <?php if(($allowedit ?? 0)!=1) echo 'checked="checked"'; ?> />一般处理</label>
  305. </td>
  306. </tr>
  307. <tr>
  308. <th width="8%">是否成交</th>
  309. <td>
  310. <label><input type="radio" name="cs_deal" value="3" <?php if(($cs_deal ?? 0)==3) echo 'checked="checked"'; ?> />成交</label>
  311. <label><input type="radio" name="cs_deal" value="2" <?php if(($cs_deal ?? 0)==2) echo 'checked="checked"'; ?> />明确需求</label>
  312. <label><input type="radio" name="cs_deal" value="1" <?php if(($cs_deal ?? 0)==1) echo 'checked="checked"'; ?> />背景调查</label>
  313. <label><input type="radio" name="cs_deal" value="0" <?php if(($cs_deal ?? 0)==0) echo 'checked="checked"'; ?> />无响应</label>
  314. </td>
  315. </tr>
  316. <tr>
  317. <th>内容</th>
  318. <td><textarea id="no_content" name="no_content" class="txt2"><?php echo $cs_note ?? ''; ?></textarea></td>
  319. </tr>
  320. <tr>
  321. <th></th>
  322. <td>
  323. <input type="submit" name="save" id="save" value="确定" class="btn1" />
  324. <input type="reset" name="save" id="save" value="重置" class="btn1" />
  325. <input type="button" value="返回" class="btn1" onClick="location.href='<?php echo $hrefstr; ?>'" />
  326. </td>
  327. </tr>
  328. </tbody>
  329. </table>
  330. </form>
  331. <?php
  332. exit;
  333. }
  334. // 批量操作
  335. if ($act == "postchk") {
  336. $keys = urlencode($_GET['Keys'] ?? '');
  337. $page = $_GET['Page'] ?? '';
  338. $chkact = $_POST['chkact'] ?? '';
  339. if (isset($_POST['chkbox']) && is_array($_POST['chkbox'])) {
  340. $ids = array_map('intval', $_POST['chkbox']);
  341. $idList = implode(',', $ids);
  342. if (!empty($idList)) {
  343. switch($chkact) {
  344. case "0":
  345. case "1":
  346. $sql = "UPDATE customer SET cs_state=$chkact WHERE id IN ($idList)";
  347. break;
  348. default:
  349. $sql = "DELETE FROM customer WHERE id IN ($idList)";
  350. }
  351. $conn->query($sql);
  352. }
  353. }
  354. header("Location: ?Keys=$keys&Page=$page");
  355. exit;
  356. }
  357. // 主列表页面
  358. $fliterQudao = $_GET['fliterQudao'] ?? '';
  359. $fliterDeal = $_GET['fliterDeal'] ?? '';
  360. $fliterTeam = $_GET['fliterTeam'] ?? '';
  361. $fliterContact = $_GET['fliterContact'] ?? '';
  362. $fliterEmployee = $_GET['fliterEmployee'] ?? '';
  363. $filterStr = "";
  364. $urlStr = "";
  365. if (!empty($fliterQudao)) {
  366. $filterStr .= " AND cs_from=" . intval($fliterQudao);
  367. $urlStr .= "&fliterQudao=$fliterQudao";
  368. }
  369. if (!empty($fliterDeal)) {
  370. $filterStr .= " AND cs_deal=" . intval($fliterDeal);
  371. $urlStr .= "&fliterDeal=$fliterDeal";
  372. }
  373. if (!empty($fliterTeam)) {
  374. $filterStr .= " AND (cs_belong=" . intval($fliterTeam) .
  375. " OR cs_belong IN (SELECT id FROM employee WHERE em_role=" . intval($fliterTeam) . "))";
  376. $urlStr .= "&fliterTeam=$fliterTeam";
  377. }
  378. if (!empty($fliterEmployee)) {
  379. $filterStr .= " AND cs_belong=" . intval($fliterEmployee);
  380. $urlStr .= "&fliterEmployee=$fliterEmployee";
  381. }
  382. if (!empty($fliterContact)) {
  383. switch($fliterContact) {
  384. case "1": $filterStr .= " AND cs_tel<>''"; break;
  385. case "2": $filterStr .= " AND cs_wechat<>''"; break;
  386. case "3": $filterStr .= " AND cs_whatsapp<>''"; break;
  387. case "4": $filterStr .= " AND cs_email<>''"; break;
  388. case "5": $filterStr .= " AND cs_linkedin<>''"; break;
  389. case "6": $filterStr .= " AND cs_facebook<>''"; break;
  390. default: $filterStr .= " AND cs_alibaba<>''";
  391. }
  392. $urlStr .= "&fliterContact=$fliterContact";
  393. }
  394. $keys = $_GET['Keys'] ?? '';
  395. $keyscode = textEncode($keys);
  396. $page = $_GET['Page'] ?? '';
  397. $ord = $_GET['Ord'] ?? '';
  398. $sql = "SELECT id, cs_code, cs_name, cs_country, cs_address, cs_tel, cs_email,
  399. cs_whatsapp, cs_wechat, cs_linkedin, cs_facebook, cs_addtime,
  400. cs_alibaba, cs_from, cs_deal, cs_updatetime, cs_belong, cs_note,
  401. cs_claimFrom, cs_chain, cs_dealdate
  402. FROM customer
  403. WHERE (cs_code LIKE '%$keyscode%'
  404. OR cs_name LIKE '%$keyscode%'
  405. OR cs_wechat LIKE '%$keyscode%'
  406. OR cs_alibaba LIKE '%$keyscode%'
  407. OR cs_telformat LIKE '%$keyscode%'
  408. OR cs_whatsappformat LIKE '%$keyscode%'
  409. OR cs_email LIKE '%$keyscode%')
  410. $filterStr
  411. ORDER BY cs_updatetime DESC";
  412. $result = $conn->query($sql);
  413. ?>
  414. <form id="form1" method="post" action="?act=postchk&Keys=<?php echo $keys; ?>&Page=<?php echo $page; ?>" onSubmit="return false">
  415. <div class="fastSelect clear">
  416. <H1>搜索条件</H1>
  417. <div class="selectItem">
  418. <label>来源渠道</label>
  419. <select name="fliterQudao" class="filterSearch">
  420. <option value="">请选择渠道</option>
  421. <?php
  422. $sql_temp = "SELECT id,ch_name FROM qudao";
  423. $qudaoResult = $conn->query($sql_temp);
  424. while($row = $qudaoResult->fetch_assoc()) {
  425. $selected = ($fliterQudao == $row['id']) ? ' selected="selected"' : '';
  426. echo "<option value=\"{$row['id']}\"$selected>{$row['ch_name']}</option>";
  427. }
  428. ?>
  429. </select>
  430. </div>
  431. <div class="selectItem">
  432. <label>是否成交</label>
  433. <select name="fliterDeal" class="filterSearch">
  434. <option value="">请选择</option>
  435. <option value="3" <?php if($fliterDeal=="3") echo 'selected="selected"'; ?>>已成交</option>
  436. <option value="2" <?php if($fliterDeal=="2") echo 'selected="selected"'; ?>>明确需求</option>
  437. <option value="1" <?php if($fliterDeal=="1") echo 'selected="selected"'; ?>>背景调查</option>
  438. <option value="0" <?php if($fliterDeal=="0") echo 'selected="selected"'; ?>>无响应</option>
  439. </select>
  440. </div>
  441. <div class="selectItem">
  442. <label>按组</label>
  443. <select name="fliterTeam" class="filterSearch">
  444. <option value="">请选择</option>
  445. <?php
  446. $sql_temp = "SELECT id,em_user FROM employee WHERE em_role=0";
  447. $teamResult = $conn->query($sql_temp);
  448. while($row = $teamResult->fetch_assoc()) {
  449. $selected = ($fliterTeam == $row['id']) ? ' selected="selected"' : '';
  450. echo "<option value=\"{$row['id']}\"$selected>{$row['em_user']}组</option>";
  451. }
  452. ?>
  453. </select>
  454. </div>
  455. <div class="selectItem">
  456. <label>业务</label>
  457. <select name="fliterEmployee" class="filterSearch">
  458. <option value="">请选择</option>
  459. <?php
  460. $sql_temp = "SELECT id,em_user FROM employee";
  461. $empResult = $conn->query($sql_temp);
  462. while($row = $empResult->fetch_assoc()) {
  463. $selected = ($fliterEmployee == $row['id']) ? ' selected="selected"' : '';
  464. echo "<option value=\"{$row['id']}\"$selected>{$row['em_user']}</option>";
  465. }
  466. ?>
  467. </select>
  468. </div>
  469. <div class="selectItem">
  470. <label>联系方式</label>
  471. <select name="fliterContact" class="filterSearch">
  472. <option value="">请选择</option>
  473. <option value="1" <?php if($fliterContact=="1") echo 'selected="selected"'; ?>>电话</option>
  474. <option value="2" <?php if($fliterContact=="2") echo 'selected="selected"'; ?>>微信</option>
  475. <option value="3" <?php if($fliterContact=="3") echo 'selected="selected"'; ?>>WhatsApp</option>
  476. <option value="4" <?php if($fliterContact=="4") echo 'selected="selected"'; ?>>邮箱</option>
  477. <option value="5" <?php if($fliterContact=="5") echo 'selected="selected"'; ?>>领英</option>
  478. <option value="6" <?php if($fliterContact=="6") echo 'selected="selected"'; ?>>Facebook</option>
  479. <option value="7" <?php if($fliterContact=="7") echo 'selected="selected"'; ?>>阿里巴巴</option>
  480. </select>
  481. </div>
  482. <div class="inputSearch">
  483. <input type="text" id="keys" class="inputTxt" value="<?php echo empty($keyscode) ? '请输入搜索关键词' : $keyscode; ?>"
  484. onFocus="if(this.value == '<?php echo empty($keyscode) ? '请输入搜索关键词' : $keyscode; ?>'){this.value='';}"
  485. onBlur="if(this.value == ''){this.value='<?php echo empty($keyscode) ? '请输入搜索关键词' : $keyscode; ?>';}"
  486. onKeyDown="if(event.keyCode==13){location.href='?Keys='+escape(document.getElementById('keys').value)+'<?php echo $urlStr; ?>'}" />
  487. <input type="button" id="searchgo" class="searchgo" value="go"
  488. onClick="location.href='?Keys='+escape(document.getElementById('keys').value)+'<?php echo $urlStr; ?>'" />
  489. </div>
  490. </div>
  491. <table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
  492. <thead>
  493. <tr>
  494. <th width="4%"><input type="checkbox" name="chkall" id="chkall" onClick="chkboxall(this,'chkbox')" /></th>
  495. <th width="6%">序号</th>
  496. <th width="20%">客户编码</th>
  497. <th width="10%">联系人</th>
  498. <th width="10%">国家地区</th>
  499. <th width="7.5%">来源</th>
  500. <th width="7.5%">是否成交</th>
  501. <th width="10%">业务员</th>
  502. <th width="10%">操作</th>
  503. </tr>
  504. </thead>
  505. <tbody>
  506. <?php
  507. if ($result->num_rows > 0) {
  508. $pageSize = 18;
  509. $totalPages = ceil($result->num_rows / $pageSize);
  510. if (empty($page)) $page = 1;
  511. if ($page == 'end') $page = $totalPages;
  512. if (!is_numeric($page) || $page < 1) $page = 1;
  513. $page = (int)$page;
  514. if ($page > $totalPages) $page = $totalPages;
  515. $offset = ($page - 1) * $pageSize;
  516. $sql .= " LIMIT $offset, $pageSize";
  517. $result = $conn->query($sql);
  518. $tempNum = $pageSize * ($page - 1);
  519. while ($row = $result->fetch_assoc()) {
  520. $tempNum++;
  521. ?>
  522. <tr onMouseOver="this.style.background='#F7FCFF'" onMouseOut="this.style.background='#FFFFFF'">
  523. <td align="center"><input type="checkbox" name="chkbox" value="<?php echo $row['id'] ?? ''; ?>" /></td>
  524. <td align="center"><?php echo $tempNum; ?></td>
  525. <td align="center" class="code" data-id="<?php echo $row['id'] ?? ''; ?>">
  526. <?php
  527. echo $row['cs_code'] ?? ''; ?>
  528. <?php if(($row['cs_claimFrom'] ?? 0) > 0): ?>
  529. <img src="../images/yijiao.png" class="handover">
  530. <?php endif; ?>
  531. </td>
  532. <td align="center"><?php echo $row['cs_name'] ?? ''; ?></td>
  533. <td align="center">
  534. <?php
  535. $countryId = intval($row['cs_country'] ?? 0);
  536. $sql = "SELECT countryName FROM country WHERE id = ?";
  537. $stmt = $conn->prepare($sql);
  538. $stmt->bind_param("i", $countryId);
  539. $stmt->execute();
  540. $countryResult = $stmt->get_result();
  541. if ($countryRow = $countryResult->fetch_assoc()) {
  542. echo htmlspecialchars($countryRow['countryName']);
  543. } else {
  544. echo "未选择";
  545. }
  546. $stmt->close();
  547. ?>
  548. </td>
  549. <td align="center">
  550. <?php
  551. $fromId = intval($row['cs_from'] ?? 0);
  552. $sql = "SELECT ch_name FROM qudao WHERE id = ?";
  553. $stmt = $conn->prepare($sql);
  554. $stmt->bind_param("i", $fromId);
  555. $stmt->execute();
  556. $qudaoResult = $stmt->get_result();
  557. if ($qudaoRow = $qudaoResult->fetch_assoc()) {
  558. echo htmlspecialchars($qudaoRow['ch_name']);
  559. } else {
  560. echo "未选择";
  561. }
  562. $stmt->close();
  563. ?>
  564. </td>
  565. <td align="center">
  566. <?php
  567. $cs_deal = intval($row['cs_deal'] ?? 0);
  568. if ($cs_deal == 3) {
  569. echo "<span style='color:red;font-size:10px;'>" . htmlspecialchars($row['cs_dealdate'] ?? '') . "成交</span>";
  570. } elseif ($cs_deal == 2) {
  571. echo "明确需求";
  572. } elseif ($cs_deal == 1) {
  573. echo "背景调查";
  574. } else {
  575. echo "无响应";
  576. }
  577. ?>
  578. </td>
  579. <td align="center">
  580. <?php
  581. $belongId = intval($row['cs_belong'] ?? 0);
  582. $sql = "SELECT em_user FROM employee WHERE id = ?";
  583. $stmt = $conn->prepare($sql);
  584. $stmt->bind_param("i", $belongId);
  585. $stmt->execute();
  586. $empResult = $stmt->get_result();
  587. if ($empRow = $empResult->fetch_assoc()) {
  588. echo htmlspecialchars($empRow['em_user']);
  589. } else {
  590. echo "未选择";
  591. }
  592. $stmt->close();
  593. ?>
  594. </td>
  595. <td align="center">
  596. <a href="?Keys=<?php echo urlencode($keys ?? ''); ?>&Page=<?php echo urlencode($page ?? '') . $urlStr; ?>&act=edit&id=<?php echo $row['id'] ?? ''; ?>" class="ico_edit ico">修改</a>
  597. </td>
  598. </tr>
  599. <tr class="detail_panel code<?php echo $row['id'] ?? ''; ?>__panel">
  600. <td colspan="2"></td>
  601. <td colspan="7" class="cs_detail">
  602. <ul>
  603. <li class="cs_detail_addtime">录入时间:<?php echo htmlspecialchars($row['cs_addtime'] ?? ''); ?></li>
  604. <li class="cs_detail_addtime">更新时间:<?php echo htmlspecialchars($row['cs_updatetime'] ?? ''); ?></li>
  605. <li class="cs_detail_addtime">
  606. 流转记录:
  607. <?php
  608. $chain = $row['cs_chain'] ?? '';
  609. if(!empty($chain)) {
  610. $chain_array = explode(',', $chain);
  611. $chain_ids = array_filter(array_map('intval', $chain_array));
  612. if(!empty($chain_ids)) {
  613. $placeholders = str_repeat('?,', count($chain_ids) - 1) . '?';
  614. $sql = "SELECT em_user FROM employee WHERE id IN ($placeholders)";
  615. $stmt = $conn->prepare($sql);
  616. $stmt->bind_param(str_repeat('i', count($chain_ids)), ...$chain_ids);
  617. $stmt->execute();
  618. $chainResult = $stmt->get_result();
  619. $chain_users = [];
  620. while($chainRow = $chainResult->fetch_assoc()) {
  621. $chain_users[] = htmlspecialchars($chainRow['em_user']);
  622. }
  623. echo implode(' > ', $chain_users);
  624. $stmt->close();
  625. }
  626. }
  627. ?>
  628. </li>
  629. <?php if(!empty($row['cs_tel'] ?? '')): ?>
  630. <li class="tel"><?php echo htmlspecialchars($row['cs_tel']); ?></li>
  631. <?php endif; ?>
  632. <?php if(!empty($row['cs_email'] ?? '')): ?>
  633. <li class="mail"><?php echo htmlspecialchars($row['cs_email']); ?></li>
  634. <?php endif; ?>
  635. <?php if(!empty($row['cs_whatsapp'] ?? '')): ?>
  636. <li class="whatsapp"><?php echo htmlspecialchars($row['cs_whatsapp']); ?></li>
  637. <?php endif; ?>
  638. <?php if(!empty($row['cs_wechat'] ?? '')): ?>
  639. <li class="wechat"><?php echo htmlspecialchars($row['cs_wechat']); ?></li>
  640. <?php endif; ?>
  641. <?php if(!empty($row['cs_linkedin'] ?? '')): ?>
  642. <li class="linkedin"><?php echo htmlspecialchars($row['cs_linkedin']); ?></li>
  643. <?php endif; ?>
  644. <?php if(!empty($row['cs_facebook'] ?? '')): ?>
  645. <li class="facebook"><?php echo htmlspecialchars($row['cs_facebook']); ?></li>
  646. <?php endif; ?>
  647. <?php if(!empty($row['cs_alibaba'] ?? '')): ?>
  648. <li class="alibaba"><?php echo htmlspecialchars($row['cs_alibaba']); ?></li>
  649. <?php endif; ?>
  650. <?php if(!empty($row['cs_address'] ?? '')): ?>
  651. <li class="address"><?php echo htmlspecialchars($row['cs_address']); ?></li>
  652. <?php endif; ?>
  653. </ul>
  654. <div class="cs_detail_note"><?php echo htmlspecialchars($row['cs_note'] ?? ''); ?></div>
  655. </td>
  656. </tr>
  657. <?php
  658. }
  659. } else {
  660. if (empty($keys)) {
  661. ?>
  662. <tr>
  663. <td align="center" colspan="9">Sorry,当前暂无信息</td>
  664. </tr>
  665. <?php
  666. } else {
  667. ?>
  668. <tr>
  669. <td align="center" colspan="9"><a href="?">Sorry,没有找到"<?php echo $keyscode; ?>"相关的信息,点击返回</a></td>
  670. </tr>
  671. <?php
  672. }
  673. }
  674. ?>
  675. </tbody>
  676. <tfoot>
  677. <tr>
  678. <td colspan="9">
  679. <div class="showpagebox">
  680. <?php
  681. if ($totalPages > 1) {
  682. $pageName = "?Keys=$keys&Ord=$ord$urlStr&";
  683. $pageLen = 3;
  684. if ($page > 1) {
  685. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  686. echo "<a href=\"{$pageName}Page=" . ($page-1) . "\">上一页</a>";
  687. }
  688. if ($pageLen * 2 + 1 >= $totalPages) {
  689. $startPage = 1;
  690. $endPage = $totalPages;
  691. } else {
  692. if ($page <= $pageLen + 1) {
  693. $startPage = 1;
  694. $endPage = $pageLen * 2 + 1;
  695. } else {
  696. $startPage = $page - $pageLen;
  697. $endPage = $page + $pageLen;
  698. }
  699. if ($page + $pageLen > $totalPages) {
  700. $startPage = $totalPages - $pageLen * 2;
  701. $endPage = $totalPages;
  702. }
  703. }
  704. for ($i = $startPage; $i <= $endPage; $i++) {
  705. if ($i == $page) {
  706. echo "<a class=\"current\">$i</a>";
  707. } else {
  708. echo "<a href=\"{$pageName}Page=$i\">$i</a>";
  709. }
  710. }
  711. if ($page < $totalPages) {
  712. if ($totalPages - $page > $pageLen) {
  713. echo "<a href=\"{$pageName}Page=$totalPages\">...$totalPages</a>";
  714. }
  715. echo "<a href=\"{$pageName}Page=" . ($page+1) . "\">下一页</a>";
  716. echo "<a href=\"{$pageName}Page=$totalPages\">尾页</a>";
  717. }
  718. echo "<input type=\"text\" id=\"Pagego\" value=\"$page\"
  719. onFocus=\"if(this.value == '$page'){this.value='';}\"
  720. onBlur=\"if(this.value == ''){this.value='$page';}\"
  721. onKeyUp=\"this.value=this.value.replace(/\D/g,'')\"
  722. onKeyDown=\"if(event.keyCode==13){location.href='{$pageName}Page='+document.getElementById('Pagego').value}\" />";
  723. }
  724. ?>
  725. </div>
  726. <div class="postchkbox">
  727. <select id="chkact" name="chkact">
  728. <option value="1">显示</option>
  729. <option value="0">隐藏</option>
  730. <option value="-1">删除</option>
  731. </select>
  732. <input type="button" value="执行" onClick="postchk(1)" class="btn1" />
  733. <input type="button" value="新增" onClick="location.href='?act=add'" class="btn1" />
  734. </div>
  735. </td>
  736. </tr>
  737. </tfoot>
  738. </table>
  739. </form>
  740. </div>
  741. </body>
  742. </html>
  743. <?php
  744. $conn->close();
  745. ?>