customers.php 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190
  1. <?php
  2. require_once('conn.php');
  3. checkLogin("信息管理");
  4. // 辅助函数
  5. function numFormat($str) {
  6. // 移除所有非数字字符
  7. $formatted = preg_replace('/[^0-9]/', '', $str);
  8. return $formatted;
  9. }
  10. // Initialize variables
  11. $urlStr = "";
  12. $act = $_GET['act'] ?? '';
  13. $output = '';
  14. // Process all actions that might need headers
  15. if ($act == "save") {
  16. $isEdit = false;
  17. $id = $_POST['id'] ?? '';
  18. if (!empty($id) && is_numeric($id)) {
  19. $isEdit = true;
  20. }
  21. // Main customer table fields
  22. $cs_code = textEncode($_POST['cs_code'] ?? '');
  23. $cs_company = textEncode($_POST['cs_company'] ?? '');
  24. $cs_belong = intval($_POST['cs_belong'] ?? 0);
  25. $cs_country = intval($_POST['cs_country'] ?? 0);
  26. $cs_from = intval($_POST['cs_from'] ?? 0);
  27. $cs_state = intval($_POST['cs_state'] ?? 0);
  28. $cs_deal = intval($_POST['cs_deal'] ?? 0);
  29. $no_content = htmlEncode($_POST['no_content'] ?? '');
  30. $cs_address = textEncode($_POST['cs_address'] ?? '');
  31. $allowedit = isset($_POST['allowedit']) ? 1 : 0;
  32. // Begin transaction for all database operations
  33. $conn->begin_transaction();
  34. try {
  35. if ($isEdit) {
  36. // Get existing chain info
  37. $sql = "SELECT cs_chain FROM customer WHERE id=$id";
  38. $result = $conn->query($sql);
  39. if ($row = $result->fetch_assoc()) {
  40. $cs_chain = $row['cs_chain'];
  41. $chain_array = explode(',', $cs_chain);
  42. $last_item = end($chain_array);
  43. if ($last_item != $cs_belong) {
  44. $cs_chain .= ",$cs_belong";
  45. }
  46. // Update customer table
  47. $sql = "UPDATE customer SET
  48. cs_code='$cs_code',
  49. cs_company='$cs_company',
  50. cs_belong=$cs_belong,
  51. cs_country=$cs_country,
  52. cs_from=$cs_from,
  53. cs_state=$cs_state,
  54. cs_deal=$cs_deal,
  55. cs_note='$no_content',
  56. cs_address='$cs_address',
  57. allowedit=$allowedit,
  58. cs_chain='$cs_chain',
  59. cs_updatetime=NOW()
  60. WHERE id=$id";
  61. $conn->query($sql);
  62. // Delete existing contacts to replace with new ones
  63. $sql = "DELETE FROM customer_contact WHERE customer_id=$id";
  64. $conn->query($sql);
  65. } else {
  66. throw new Exception('不存在该客户');
  67. }
  68. } else {
  69. // Insert new customer
  70. $sql = "INSERT INTO customer (
  71. cs_code, cs_company, cs_belong, cs_country, cs_from,
  72. cs_state, cs_deal, cs_note, cs_address,
  73. allowedit, cs_chain, cs_addtime, cs_updatetime
  74. ) VALUES (
  75. '$cs_code', '$cs_company', $cs_belong, $cs_country, $cs_from,
  76. $cs_state, $cs_deal, '$no_content', '$cs_address',
  77. $allowedit, '$cs_belong', NOW(), NOW()
  78. )";
  79. $conn->query($sql);
  80. $id = $conn->insert_id;
  81. }
  82. // Process contacts array
  83. if (isset($_POST['contact']) && is_array($_POST['contact'])) {
  84. foreach ($_POST['contact'] as $contact) {
  85. if (empty($contact['contact_name'])) continue;
  86. $contact_name = textEncode($contact['contact_name']);
  87. // Initialize arrays for contact methods
  88. $methods = ['tel', 'email', 'whatsapp', 'wechat', 'linkedin', 'facebook', 'alibaba'];
  89. $fields = ['customer_id', 'contact_name'];
  90. $values = [$id, "'$contact_name'"];
  91. // Process each contact method (up to 3 entries each)
  92. foreach ($methods as $method) {
  93. for ($i = 1; $i <= 3; $i++) {
  94. $field_base = $method . '_' . $i;
  95. $value = textEncode($contact[$field_base] ?? '');
  96. $fields[] = $field_base;
  97. $values[] = "'$value'";
  98. // Add format field for tel and whatsapp
  99. if ($method == 'tel' || $method == 'whatsapp') {
  100. $format_value = numFormat($value);
  101. $fields[] = $field_base . '_format';
  102. $values[] = "'$format_value'";
  103. }
  104. // Add backup field
  105. $bu_value = textEncode($contact[$field_base . '_bu'] ?? $value);
  106. $fields[] = $field_base . '_bu';
  107. $values[] = "'$bu_value'";
  108. }
  109. }
  110. // Create and execute insert statement for contact
  111. $sql = "INSERT INTO customer_contact (" . implode(', ', $fields) . ", created_at, updated_at)
  112. VALUES (" . implode(', ', $values) . ", NOW(), NOW())";
  113. $conn->query($sql);
  114. }
  115. }
  116. // Commit transaction
  117. $conn->commit();
  118. // Redirect after successful save
  119. $page = $_GET['Page'] ?? '';
  120. $keys = urlencode($_GET['Keys'] ?? '');
  121. header("Location: ?keys=$keys&Page=$page$urlStr");
  122. exit;
  123. } catch (Exception $e) {
  124. // Rollback on failure
  125. $conn->rollback();
  126. $output = "<script>alert('保存失败: " . $e->getMessage() . "');history.back();</script>";
  127. }
  128. }
  129. // If we have output from processing, we'll show it instead of the normal page
  130. if (!empty($output)) {
  131. echo $output;
  132. exit;
  133. }
  134. ?>
  135. <!DOCTYPE html>
  136. <html xmlns="http://www.w3.org/1999/xhtml">
  137. <head>
  138. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  139. <title>管理区域</title>
  140. <link rel="stylesheet" href="css/common.css" type="text/css" />
  141. <script language="javascript" src="js/jquery-1.7.2.min.js"></script>
  142. <script type="text/javascript" src="js/js.js"></script>
  143. <script type="text/javascript" src="xheditor-1.1.9/xheditor-1.1.9-zh-cn.min.js"></script>
  144. <script>
  145. $(document).ready(function(){
  146. $('.txt2').xheditor({
  147. tools:'full',
  148. hoverExecDelay:-1,
  149. urlBase:'system/',
  150. upLinkUrl:"upload.php",
  151. upLinkExt:"zip,rar,txt,pdf",
  152. upImgUrl:"upload.php",
  153. upImgExt:"jpg,jpeg,gif,png",
  154. upFlashUrl:"upload.php",
  155. upFlashExt:"swf",
  156. upMediaUrl:"upload.php",
  157. upMediaExt:"wmv,avi,wma,mp3,mid"
  158. });
  159. // Remove contact
  160. $(document).on('click', '.remove-contact-btn', function() {
  161. var contactForm = $(this).closest('.contact-form');
  162. contactForm.remove();
  163. // Renumber remaining contacts
  164. $('#contacts-container .contact-form').each(function(index) {
  165. $(this).find('h3').text('联系人 #' + (index + 1));
  166. });
  167. });
  168. // Add contact form
  169. $('.add-contact-btn').click(function() {
  170. var contactsContainer = $('#contacts-container');
  171. var contactIndex = contactsContainer.children('.contact-form').length;
  172. var contactForm = `
  173. <div class="contact-form" id="contact-form-${contactIndex}">
  174. <div class="contact-header">
  175. <button type="button" class="remove-contact-btn" data-index="${contactIndex}">删除</button>
  176. <h3>联系人 #${contactIndex + 1}</h3>
  177. </div>
  178. <input type="hidden" name="contact[${contactIndex}][id]" value="">
  179. <table width="100%" border="0" cellpadding="3" cellspacing="1" class="contact-table">
  180. <tr>
  181. <th width="8%">联系人</th>
  182. <td><input type="text" name="contact[${contactIndex}][contact_name]" class="txt1" placeholder="联系人姓名"/></td>
  183. </tr>
  184. </table>
  185. <div class="contact-methods-container" id="contact-methods-${contactIndex}">
  186. <!-- Contact methods will be added here -->
  187. </div>
  188. <button type="button" class="add-method-btn" data-contact-index="${contactIndex}">添加联系方式</button>
  189. </div>
  190. `;
  191. contactsContainer.append(contactForm);
  192. });
  193. // Add contact method
  194. $(document).on('click', '.add-method-btn', function() {
  195. var contactIndex = $(this).data('contact-index');
  196. var methodsContainer = $('#contact-methods-' + contactIndex);
  197. // Count existing methods by type
  198. var methodCounts = {};
  199. methodsContainer.find('select.method-select').each(function() {
  200. var type = $(this).val();
  201. if (type) {
  202. methodCounts[type] = (methodCounts[type] || 0) + 1;
  203. }
  204. });
  205. var methodRow = `
  206. <div class="contact-method-row">
  207. <select class="method-select" onchange="updateMethodSelectAndPlaceholder(this)">
  208. <option value="">请选择联系方式</option>
  209. <option value="tel" ${(methodCounts.tel || 0) >= 3 ? 'disabled' : ''}>电话</option>
  210. <option value="wechat" ${(methodCounts.wechat || 0) >= 3 ? 'disabled' : ''}>微信</option>
  211. <option value="whatsapp" ${(methodCounts.whatsapp || 0) >= 3 ? 'disabled' : ''}>WhatsApp</option>
  212. <option value="email" ${(methodCounts.email || 0) >= 3 ? 'disabled' : ''}>邮箱</option>
  213. <option value="linkedin" ${(methodCounts.linkedin || 0) >= 3 ? 'disabled' : ''}>领英</option>
  214. <option value="facebook" ${(methodCounts.facebook || 0) >= 3 ? 'disabled' : ''}>Facebook</option>
  215. <option value="alibaba" ${(methodCounts.alibaba || 0) >= 3 ? 'disabled' : ''}>阿里巴巴</option>
  216. </select>
  217. <input type="text" class="txt1 method-input" style="width:60%;" placeholder="请选择联系方式类型">
  218. <button type="button" class="remove-method-btn">删除</button>
  219. </div>
  220. `;
  221. methodsContainer.append(methodRow);
  222. updateMethodFields(methodsContainer.find('.contact-method-row:last-child'));
  223. });
  224. // Remove contact method
  225. $(document).on('click', '.remove-method-btn', function() {
  226. var methodRow = $(this).closest('.contact-method-row');
  227. var contactIndex = methodRow.closest('.contact-form').attr('id').split('-')[2];
  228. var type = methodRow.find('select.method-select').val();
  229. methodRow.remove();
  230. // Update available options in other selects
  231. updateAvailableMethodTypes(contactIndex);
  232. });
  233. });
  234. // Update method fields based on selection
  235. function updateMethodFields(methodRow) {
  236. var select = methodRow.find('select.method-select');
  237. var input = methodRow.find('input.method-input');
  238. var contactForm = methodRow.closest('.contact-form');
  239. var contactIndex = contactForm.attr('id').split('-')[2];
  240. var type = select.val();
  241. if (!type) return;
  242. // Count existing methods of this type
  243. var count = 1;
  244. contactForm.find('select.method-select').each(function() {
  245. if ($(this).val() === type && $(this)[0] !== select[0]) {
  246. count++;
  247. }
  248. });
  249. // Update field names
  250. select.attr('name', `contact[${contactIndex}][${type}_${count}]`);
  251. input.attr('name', `contact[${contactIndex}][${type}_${count}]`);
  252. // Add format field for tel and whatsapp
  253. if (type === 'tel' || type === 'whatsapp') {
  254. if (!methodRow.find('.format-input').length) {
  255. input.after(`<input type="hidden" class="format-input" name="contact[${contactIndex}][${type}_${count}_format]">`);
  256. }
  257. }
  258. // Add backup field
  259. if (!methodRow.find('.backup-input').length) {
  260. methodRow.append(`<input type="hidden" class="backup-input" name="contact[${contactIndex}][${type}_${count}_bu]">`);
  261. }
  262. }
  263. // Update available method types for a contact
  264. function updateAvailableMethodTypes(contactIndex) {
  265. var methodsContainer = $('#contact-methods-' + contactIndex);
  266. // Count methods by type
  267. var methodCounts = {};
  268. methodsContainer.find('select.method-select').each(function() {
  269. var type = $(this).val();
  270. if (type) {
  271. methodCounts[type] = (methodCounts[type] || 0) + 1;
  272. }
  273. });
  274. // Update all selects in this contact
  275. methodsContainer.find('select.method-select').each(function() {
  276. var currentValue = $(this).val();
  277. $(this).find('option').each(function() {
  278. var optionValue = $(this).val();
  279. if (optionValue && optionValue !== currentValue) {
  280. $(this).prop('disabled', (methodCounts[optionValue] || 0) >= 3);
  281. }
  282. });
  283. });
  284. }
  285. // Update placeholder and handle method fields
  286. function updateMethodSelectAndPlaceholder(selectElement) {
  287. var methodRow = $(selectElement).closest('.contact-method-row');
  288. updateMethodPlaceholder(selectElement);
  289. updateMethodFields(methodRow);
  290. var contactIndex = methodRow.closest('.contact-form').attr('id').split('-')[2];
  291. updateAvailableMethodTypes(contactIndex);
  292. }
  293. function updateMethodPlaceholder(selectElement) {
  294. var placeholder = "";
  295. var value = $(selectElement).val();
  296. switch(value) {
  297. case "tel":
  298. placeholder = "电话格式:区号+号码 如:+86 15012345678";
  299. break;
  300. case "wechat":
  301. placeholder = "微信";
  302. break;
  303. case "whatsapp":
  304. placeholder = "Whatsapp 格式:区号+号码 如:+86 15012345678";
  305. break;
  306. case "email":
  307. placeholder = "邮件";
  308. break;
  309. case "linkedin":
  310. placeholder = "领英链接";
  311. break;
  312. case "facebook":
  313. placeholder = "Facebook";
  314. break;
  315. case "alibaba":
  316. placeholder = "阿里巴巴";
  317. break;
  318. default:
  319. placeholder = "请选择联系方式类型";
  320. }
  321. $(selectElement).next('.method-input').attr('placeholder', placeholder);
  322. }
  323. </script>
  324. <style>
  325. .contact-form {
  326. margin-bottom: 10px;
  327. padding: 8px;
  328. background-color: #FFFFFF;
  329. }
  330. .contact-header {
  331. display: flex;
  332. align-items: center;
  333. margin-bottom: 8px;
  334. gap: 10px;
  335. }
  336. .contact-header h3 {
  337. margin: 0;
  338. order: 2;
  339. flex-grow: 1;
  340. }
  341. .remove-contact-btn {
  342. background-color: #f44336;
  343. color: white;
  344. border: none;
  345. padding: 4px 8px;
  346. cursor: pointer;
  347. order: 1;
  348. }
  349. .add-contact-btn {
  350. background-color: #4CAF50;
  351. color: white;
  352. border: none;
  353. padding: 6px 12px;
  354. margin-bottom: 10px;
  355. cursor: pointer;
  356. }
  357. .contact-methods-container {
  358. margin-top: 8px;
  359. }
  360. .contact-method-row {
  361. margin-bottom: 6px;
  362. padding: 6px;
  363. border: 1px solid #eee;
  364. display: flex;
  365. align-items: center;
  366. gap: 8px;
  367. }
  368. .add-method-btn {
  369. background-color: #2196F3;
  370. color: white;
  371. border: none;
  372. padding: 4px 8px;
  373. margin-top: 4px;
  374. cursor: pointer;
  375. }
  376. .remove-method-btn {
  377. background-color: #f44336;
  378. color: white;
  379. border: none;
  380. padding: 2px 4px;
  381. cursor: pointer;
  382. }
  383. .method-select {
  384. margin-right: 8px;
  385. padding: 3px;
  386. }
  387. .contact-table {
  388. margin-bottom: 6px;
  389. }
  390. .contact-table td, .contact-table th {
  391. padding: 4px 6px;
  392. }
  393. </style>
  394. </head>
  395. <body>
  396. <div id="man_zone">
  397. <?php
  398. // 编辑操作
  399. if ($act == "edit" || $act == "add") {
  400. $id = $_GET['id'] ?? '';
  401. $isEdit = false;
  402. // Initialize variables
  403. $cs_code = $cs_company = $cs_address = $cs_addtime = $cs_updatetime = $cs_note = '';
  404. $cs_belong = $cs_country = $cs_from = $cs_state = $cs_deal = $allowedit = $cs_type = $cs_belongclient = 0;
  405. $contacts = [];
  406. if (!empty($id) && is_numeric($id)) {
  407. $isEdit = true;
  408. // Join customer and customer_contact tables
  409. $sql = "SELECT c.*, cc.* FROM customer c
  410. LEFT JOIN customer_contact cc ON c.id = cc.customer_id
  411. WHERE c.id = $id";
  412. $result = $conn->query($sql);
  413. if ($row = $result->fetch_assoc()) {
  414. // Basic customer info
  415. $cs_code = textUncode($row['cs_code']);
  416. $cs_company = textUncode($row['cs_company']);
  417. $cs_country = $row['cs_country'];
  418. $cs_from = $row['cs_from'];
  419. $cs_address = textUncode($row['cs_address']);
  420. $cs_addtime = $row['cs_addtime'];
  421. $cs_updatetime = $row['cs_updatetime'];
  422. $cs_belong = $row['cs_belong'];
  423. $cs_state = $row['cs_state'];
  424. $cs_deal = $row['cs_deal'];
  425. $cs_note = htmlUncode($row['cs_note']);
  426. $allowedit = $row['allowedit'];
  427. $cs_type = $row['cs_type'];
  428. $cs_belongclient = $row['cs_belongclient'];
  429. // Get all contacts for this customer
  430. $contactSql = "SELECT * FROM customer_contact WHERE customer_id = $id";
  431. $contactResult = $conn->query($contactSql);
  432. while ($contactRow = $contactResult->fetch_assoc()) {
  433. $contact = [
  434. 'id' => $contactRow['id'],
  435. 'contact_name' => textUncode($contactRow['contact_name']),
  436. 'created_at' => $contactRow['created_at'],
  437. 'updated_at' => $contactRow['updated_at']
  438. ];
  439. // Process each contact method type (up to 3 entries each)
  440. $methodTypes = ['tel', 'email', 'whatsapp', 'wechat', 'linkedin', 'facebook', 'alibaba'];
  441. foreach ($methodTypes as $type) {
  442. for ($i = 1; $i <= 3; $i++) {
  443. $fieldBase = $type . '_' . $i;
  444. $contact[$fieldBase] = textUncode($contactRow[$fieldBase]);
  445. if ($type == 'tel' || $type == 'whatsapp') {
  446. $contact[$fieldBase . '_format'] = textUncode($contactRow[$fieldBase . '_format']);
  447. }
  448. $contact[$fieldBase . '_bu'] = textUncode($contactRow[$fieldBase . '_bu']);
  449. }
  450. }
  451. $contacts[] = $contact;
  452. }
  453. }
  454. }
  455. $page = $_GET['Page'] ?? '';
  456. $keys = urlencode($_GET['Keys'] ?? '');
  457. $ord = urlencode($_GET['Ord'] ?? '');
  458. $hrefstr = "?keys=$keys&Page=$page&Ord=$ord";
  459. ?>
  460. <form name="form1" method="post" action="<?php echo $hrefstr; ?>&act=save">
  461. <table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
  462. <tbody>
  463. <tr>
  464. <th width="8%">客户编号</th>
  465. <td><input type="text" id="cs_code" name="cs_code" value="<?php echo $cs_code; ?>" class="txt1" />
  466. <input type="hidden" name="id" value="<?php echo $id; ?>" /></td>
  467. </tr>
  468. <tr>
  469. <th width="8%">公司名称</th>
  470. <td><input type="text" id="cs_company" name="cs_company" value="<?php echo $cs_company; ?>" class="txt1" /></td>
  471. </tr>
  472. <tr>
  473. <th width="8%">所属业务</th>
  474. <td>
  475. <select name="cs_belong">
  476. <option value="0">请选择</option>
  477. <?php
  478. $sql = "SELECT id,em_user FROM employee";
  479. $result = $conn->query($sql);
  480. while($row = $result->fetch_assoc()) {
  481. $selected = ($row['id'] == $cs_belong) ? ' selected="selected"' : '';
  482. echo "<option value=\"{$row['id']}\"$selected>{$row['em_user']}</option>";
  483. }
  484. ?>
  485. </select>
  486. </td>
  487. </tr>
  488. <tr>
  489. <th width="8%">国家</th>
  490. <td>
  491. <select name="cs_country">
  492. <option value="0">请选择</option>
  493. <?php
  494. $sql = "SELECT id,countryCode,countryName FROM country";
  495. $result = $conn->query($sql);
  496. while($row = $result->fetch_assoc()) {
  497. $selected = ($row['id'] == $cs_country) ? ' selected="selected"' : '';
  498. echo "<option value=\"{$row['id']}\"$selected>{$row['countryName']}</option>";
  499. }
  500. ?>
  501. </select>
  502. </td>
  503. </tr>
  504. <tr>
  505. <th width="8%">来源</th>
  506. <td>
  507. <select name="cs_from">
  508. <option value="0">请选择</option>
  509. <?php
  510. $sql = "SELECT id,ch_name FROM qudao";
  511. $result = $conn->query($sql);
  512. while($row = $result->fetch_assoc()) {
  513. $selected = ($row['id'] == $cs_from) ? ' selected="selected"' : '';
  514. echo "<option value=\"{$row['id']}\"$selected>{$row['ch_name']}</option>";
  515. }
  516. ?>
  517. </select>
  518. </td>
  519. </tr>
  520. <tr>
  521. <th width="8%">录入时间</th>
  522. <td><?php echo $cs_addtime; ?></td>
  523. </tr>
  524. <tr>
  525. <th width="8%">更新时间</th>
  526. <td><?php echo $cs_updatetime; ?></td>
  527. </tr>
  528. <tr>
  529. <th width="8%" valign="top">联系人信息</th>
  530. <td>
  531. <button type="button" class="add-contact-btn">添加联系人</button>
  532. <div id="contacts-container">
  533. <?php if (!empty($contacts)): ?>
  534. <?php foreach ($contacts as $index => $contact): ?>
  535. <div class="contact-form" id="contact-form-<?php echo $index; ?>">
  536. <div class="contact-header">
  537. <button type="button" class="remove-contact-btn" data-index="<?php echo $index; ?>">删除</button>
  538. <h3>联系人 #<?php echo $index + 1; ?></h3>
  539. </div>
  540. <input type="hidden" name="contact[<?php echo $index; ?>][id]" value="<?php echo $contact['id']; ?>">
  541. <table width="100%" border="0" cellpadding="3" cellspacing="1" class="contact-table">
  542. <tr>
  543. <th width="8%">联系人</th>
  544. <td><input type="text" name="contact[<?php echo $index; ?>][contact_name]" value="<?php echo htmlspecialchars($contact['contact_name']); ?>" class="txt1" placeholder="联系人姓名"/></td>
  545. </tr>
  546. </table>
  547. <div class="contact-methods-container" id="contact-methods-<?php echo $index; ?>">
  548. <?php
  549. $methodTypes = [
  550. 'tel' => '电话',
  551. 'wechat' => '微信',
  552. 'whatsapp' => 'WhatsApp',
  553. 'email' => '邮箱',
  554. 'linkedin' => '领英',
  555. 'facebook' => 'Facebook',
  556. 'alibaba' => '阿里巴巴'
  557. ];
  558. foreach ($methodTypes as $type => $label) {
  559. for ($i = 1; $i <= 3; $i++) {
  560. $fieldName = $type . '_' . $i;
  561. if (!empty($contact[$fieldName])) {
  562. echo '<div class="contact-method-row">';
  563. echo '<select class="method-select" name="contact[' . $index . '][' . $fieldName . ']" onchange="updateMethodSelectAndPlaceholder(this)">';
  564. echo '<option value="">请选择联系方式</option>';
  565. foreach ($methodTypes as $optionType => $optionLabel) {
  566. $selected = ($optionType === $type) ? 'selected' : '';
  567. echo '<option value="' . $optionType . '" ' . $selected . '>' . $optionLabel . '</option>';
  568. }
  569. echo '</select>';
  570. echo '<input type="text" class="txt1 method-input" style="width:60%;" name="contact[' . $index . '][' . $fieldName . ']" value="' . htmlspecialchars($contact[$fieldName]) . '">';
  571. if ($type === 'tel' || $type === 'whatsapp') {
  572. echo '<input type="hidden" class="format-input" name="contact[' . $index . '][' . $fieldName . '_format]" value="' . htmlspecialchars($contact[$fieldName . '_format']) . '">';
  573. }
  574. echo '<input type="hidden" class="backup-input" name="contact[' . $index . '][' . $fieldName . '_bu]" value="' . htmlspecialchars($contact[$fieldName . '_bu']) . '">';
  575. echo '</div>';
  576. }
  577. }
  578. }
  579. ?>
  580. </div>
  581. <button type="button" class="add-method-btn" data-contact-index="<?php echo $index; ?>">添加联系方式</button>
  582. </div>
  583. <?php endforeach; ?>
  584. <?php else: ?>
  585. <div class="contact-form" id="contact-form-0">
  586. <div class="contact-header">
  587. <button type="button" class="remove-contact-btn" data-index="0">删除</button>
  588. <h3>联系人 #1</h3>
  589. </div>
  590. <input type="hidden" name="contact[0][id]" value="">
  591. <table width="100%" border="0" cellpadding="3" cellspacing="1" class="contact-table">
  592. <tr>
  593. <th width="8%">联系人</th>
  594. <td><input type="text" name="contact[0][contact_name]" class="txt1" placeholder="联系人姓名"/></td>
  595. </tr>
  596. </table>
  597. <div class="contact-methods-container" id="contact-methods-0">
  598. <!-- Contact methods will be added here -->
  599. </div>
  600. <button type="button" class="add-method-btn" data-contact-index="0">添加联系方式</button>
  601. </div>
  602. <?php endif; ?>
  603. </div>
  604. </td>
  605. </tr>
  606. <tr>
  607. <th width="8%">地址</th>
  608. <td><input type="text" id="cs_address" name="cs_address" value="<?php echo $cs_address; ?>" class="txt1" /></td>
  609. </tr>
  610. <tr>
  611. <th width="8%">标签</th>
  612. <td>
  613. <?php
  614. if($isEdit) {
  615. $sql = "SELECT id,tagName FROM tagtable WHERE customerId = " . (int)$id;
  616. $result = $conn->query($sql);
  617. while($row = $result->fetch_assoc()) {
  618. echo htmlspecialchars($row['tagName']) . ',';
  619. }
  620. }
  621. ?>
  622. </td>
  623. </tr>
  624. <tr>
  625. <th width="8%">状态</th>
  626. <td>
  627. <label><input type="radio" name="cs_state" value="1" <?php if($cs_state==1) echo 'checked="checked"'; ?> />有效</label>
  628. <label><input type="radio" name="cs_state" value="0" <?php if($cs_state!=1) echo 'checked="checked"'; ?> />不再跟进</label>
  629. </td>
  630. </tr>
  631. <tr>
  632. <th width="8%">是否误报</th>
  633. <td>
  634. <label><input type="radio" name="allowedit" value="1" <?php if($allowedit==1) echo 'checked="checked"'; ?> />审核通过</label>
  635. <label><input type="radio" name="allowedit" value="0" <?php if($allowedit!=1) echo 'checked="checked"'; ?> />一般处理</label>
  636. </td>
  637. </tr>
  638. <tr>
  639. <th width="8%">是否成交</th>
  640. <td>
  641. <label><input type="radio" name="cs_deal" value="3" <?php if($cs_deal==3) echo 'checked="checked"'; ?> />成交</label>
  642. <label><input type="radio" name="cs_deal" value="2" <?php if($cs_deal==2) echo 'checked="checked"'; ?> />明确需求</label>
  643. <label><input type="radio" name="cs_deal" value="1" <?php if($cs_deal==1) echo 'checked="checked"'; ?> />背景调查</label>
  644. <label><input type="radio" name="cs_deal" value="0" <?php if($cs_deal==0) echo 'checked="checked"'; ?> />无响应</label>
  645. </td>
  646. </tr>
  647. <tr>
  648. <th>内容</th>
  649. <td><textarea id="no_content" name="no_content" class="txt2"><?php echo $cs_note; ?></textarea></td>
  650. </tr>
  651. <tr>
  652. <th></th>
  653. <td>
  654. <input type="submit" name="save" id="save" value="确定" class="btn1" />
  655. <input type="reset" name="save" id="save" value="重置" class="btn1" />
  656. <input type="button" value="返回" class="btn1" onClick="location.href='<?php echo $hrefstr; ?>'" />
  657. </td>
  658. </tr>
  659. </tbody>
  660. </table>
  661. </form>
  662. <?php
  663. exit;
  664. }
  665. // 批量操作
  666. if ($act == "postchk") {
  667. $keys = urlencode($_GET['Keys'] ?? '');
  668. $page = $_GET['Page'] ?? '';
  669. $chkact = $_POST['chkact'] ?? '';
  670. if (isset($_POST['chkbox']) && is_array($_POST['chkbox'])) {
  671. $ids = array_map('intval', $_POST['chkbox']);
  672. $idList = implode(',', $ids);
  673. if (!empty($idList)) {
  674. switch($chkact) {
  675. case "0":
  676. case "1":
  677. $sql = "UPDATE customer SET cs_state=$chkact WHERE id IN ($idList)";
  678. break;
  679. default:
  680. // In delete case, let's use transactions to ensure both tables are updated
  681. $conn->begin_transaction();
  682. try {
  683. // Delete from customer_contact first (due to foreign key constraint)
  684. $sql = "DELETE FROM customer_contact WHERE customer_id IN ($idList)";
  685. $conn->query($sql);
  686. // Then delete from customer table
  687. $sql = "DELETE FROM customer WHERE id IN ($idList)";
  688. $conn->query($sql);
  689. $conn->commit();
  690. } catch (Exception $e) {
  691. $conn->rollback();
  692. echo "<script>alert('删除失败: " . $e->getMessage() . "');</script>";
  693. }
  694. }
  695. if ($chkact == "0" || $chkact == "1") {
  696. $conn->query($sql);
  697. }
  698. }
  699. }
  700. header("Location: ?Keys=$keys&Page=$page");
  701. exit;
  702. }
  703. // 主列表页面
  704. $fliterQudao = $_GET['fliterQudao'] ?? '';
  705. $fliterDeal = $_GET['fliterDeal'] ?? '';
  706. $fliterTeam = $_GET['fliterTeam'] ?? '';
  707. $fliterContact = $_GET['fliterContact'] ?? '';
  708. $fliterEmployee = $_GET['fliterEmployee'] ?? '';
  709. $filterStr = "";
  710. $urlStr = "";
  711. if (!empty($fliterQudao)) {
  712. $filterStr .= " AND c.cs_from=" . intval($fliterQudao);
  713. $urlStr .= "&fliterQudao=$fliterQudao";
  714. }
  715. if (!empty($fliterDeal)) {
  716. $filterStr .= " AND c.cs_deal=" . intval($fliterDeal);
  717. $urlStr .= "&fliterDeal=$fliterDeal";
  718. }
  719. if (!empty($fliterTeam)) {
  720. $filterStr .= " AND (c.cs_belong=" . intval($fliterTeam) .
  721. " OR c.cs_belong IN (SELECT id FROM employee WHERE em_role=" . intval($fliterTeam) . "))";
  722. $urlStr .= "&fliterTeam=$fliterTeam";
  723. }
  724. if (!empty($fliterEmployee)) {
  725. $filterStr .= " AND c.cs_belong=" . intval($fliterEmployee);
  726. $urlStr .= "&fliterEmployee=$fliterEmployee";
  727. }
  728. if (!empty($fliterContact)) {
  729. switch($fliterContact) {
  730. case "1": $filterStr .= " AND (cc.tel_1 != '' OR cc.tel_2 != '' OR cc.tel_3 != '')"; break;
  731. case "2": $filterStr .= " AND (cc.wechat_1 != '' OR cc.wechat_2 != '' OR cc.wechat_3 != '')"; break;
  732. case "3": $filterStr .= " AND (cc.whatsapp_1 != '' OR cc.whatsapp_2 != '' OR cc.whatsapp_3 != '')"; break;
  733. case "4": $filterStr .= " AND (cc.email_1 != '' OR cc.email_2 != '' OR cc.email_3 != '')"; break;
  734. case "5": $filterStr .= " AND (cc.linkedin_1 != '' OR cc.linkedin_2 != '' OR cc.linkedin_3 != '')"; break;
  735. case "6": $filterStr .= " AND (cc.facebook_1 != '' OR cc.facebook_2 != '' OR cc.facebook_3 != '')"; break;
  736. default: $filterStr .= " AND (cc.alibaba_1 != '' OR cc.alibaba_2 != '' OR cc.alibaba_3 != '')";
  737. }
  738. $urlStr .= "&fliterContact=$fliterContact";
  739. }
  740. $keys = $_GET['Keys'] ?? '';
  741. $keyscode = textEncode($keys);
  742. $page = $_GET['Page'] ?? '';
  743. $ord = $_GET['Ord'] ?? '';
  744. $sql = "SELECT c.id, c.cs_code, c.cs_company, c.cs_country, c.cs_address,
  745. c.cs_from, c.cs_deal, c.cs_addtime, c.cs_updatetime, c.cs_belong, c.cs_note,
  746. c.cs_claimFrom, c.cs_chain, c.cs_dealdate,
  747. cc.contact_name as cs_name,
  748. cc.tel_1 as cs_tel, cc.email_1 as cs_email,
  749. cc.whatsapp_1 as cs_whatsapp, cc.wechat_1 as cs_wechat,
  750. cc.linkedin_1 as cs_linkedin, cc.facebook_1 as cs_facebook,
  751. cc.alibaba_1 as cs_alibaba
  752. FROM customer c
  753. LEFT JOIN customer_contact cc ON c.id = cc.customer_id
  754. WHERE (c.cs_code LIKE '%$keyscode%'
  755. OR cc.contact_name LIKE '%$keyscode%'
  756. OR cc.tel_1 LIKE '%$keyscode%'
  757. OR cc.tel_2 LIKE '%$keyscode%'
  758. OR cc.tel_3 LIKE '%$keyscode%'
  759. OR cc.wechat_1 LIKE '%$keyscode%'
  760. OR cc.wechat_2 LIKE '%$keyscode%'
  761. OR cc.wechat_3 LIKE '%$keyscode%'
  762. OR cc.alibaba_1 LIKE '%$keyscode%'
  763. OR cc.alibaba_2 LIKE '%$keyscode%'
  764. OR cc.alibaba_3 LIKE '%$keyscode%'
  765. OR cc.whatsapp_1_format LIKE '%$keyscode%'
  766. OR cc.whatsapp_2_format LIKE '%$keyscode%'
  767. OR cc.whatsapp_3_format LIKE '%$keyscode%'
  768. OR cc.email_1 LIKE '%$keyscode%'
  769. OR cc.email_2 LIKE '%$keyscode%'
  770. OR cc.email_3 LIKE '%$keyscode%')
  771. $filterStr
  772. ORDER BY c.cs_updatetime DESC";
  773. $result = $conn->query($sql);
  774. $totalPages = 0;
  775. $pageSize = 18;
  776. ?>
  777. <form id="form1" method="post" action="?act=postchk&Keys=<?php echo $keys; ?>&Page=<?php echo $page; ?>" onSubmit="return false">
  778. <div class="fastSelect clear">
  779. <H1>搜索条件</H1>
  780. <div class="selectItem">
  781. <label>来源渠道</label>
  782. <select name="fliterQudao" class="filterSearch">
  783. <option value="">请选择渠道</option>
  784. <?php
  785. $sql_temp = "SELECT id,ch_name FROM qudao";
  786. $qudaoResult = $conn->query($sql_temp);
  787. while($row = $qudaoResult->fetch_assoc()) {
  788. $selected = ($fliterQudao == $row['id']) ? ' selected="selected"' : '';
  789. echo "<option value=\"{$row['id']}\"$selected>{$row['ch_name']}</option>";
  790. }
  791. ?>
  792. </select>
  793. </div>
  794. <div class="selectItem">
  795. <label>是否成交</label>
  796. <select name="fliterDeal" class="filterSearch">
  797. <option value="">请选择</option>
  798. <option value="3" <?php if($fliterDeal=="3") echo 'selected="selected"'; ?>>已成交</option>
  799. <option value="2" <?php if($fliterDeal=="2") echo 'selected="selected"'; ?>>明确需求</option>
  800. <option value="1" <?php if($fliterDeal=="1") echo 'selected="selected"'; ?>>背景调查</option>
  801. <option value="0" <?php if($fliterDeal=="0") echo 'selected="selected"'; ?>>无响应</option>
  802. </select>
  803. </div>
  804. <div class="selectItem">
  805. <label>按组</label>
  806. <select name="fliterTeam" class="filterSearch">
  807. <option value="">请选择</option>
  808. <?php
  809. $sql_temp = "SELECT id,em_user FROM employee WHERE em_role=0";
  810. $teamResult = $conn->query($sql_temp);
  811. while($row = $teamResult->fetch_assoc()) {
  812. $selected = ($fliterTeam == $row['id']) ? ' selected="selected"' : '';
  813. echo "<option value=\"{$row['id']}\"$selected>{$row['em_user']}组</option>";
  814. }
  815. ?>
  816. </select>
  817. </div>
  818. <div class="selectItem">
  819. <label>业务</label>
  820. <select name="fliterEmployee" class="filterSearch">
  821. <option value="">请选择</option>
  822. <?php
  823. $sql_temp = "SELECT id,em_user FROM employee";
  824. $empResult = $conn->query($sql_temp);
  825. while($row = $empResult->fetch_assoc()) {
  826. $selected = ($fliterEmployee == $row['id']) ? ' selected="selected"' : '';
  827. echo "<option value=\"{$row['id']}\"$selected>{$row['em_user']}</option>";
  828. }
  829. ?>
  830. </select>
  831. </div>
  832. <div class="selectItem">
  833. <label>联系方式</label>
  834. <select name="fliterContact" class="filterSearch">
  835. <option value="">请选择</option>
  836. <option value="1" <?php if($fliterContact=="1") echo 'selected="selected"'; ?>>电话</option>
  837. <option value="2" <?php if($fliterContact=="2") echo 'selected="selected"'; ?>>微信</option>
  838. <option value="3" <?php if($fliterContact=="3") echo 'selected="selected"'; ?>>WhatsApp</option>
  839. <option value="4" <?php if($fliterContact=="4") echo 'selected="selected"'; ?>>邮箱</option>
  840. <option value="5" <?php if($fliterContact=="5") echo 'selected="selected"'; ?>>领英</option>
  841. <option value="6" <?php if($fliterContact=="6") echo 'selected="selected"'; ?>>Facebook</option>
  842. <option value="7" <?php if($fliterContact=="7") echo 'selected="selected"'; ?>>阿里巴巴</option>
  843. </select>
  844. </div>
  845. <div class="inputSearch">
  846. <input type="text" id="keys" class="inputTxt" value="<?php echo empty($keyscode) ? '请输入搜索关键词' : $keyscode; ?>"
  847. onFocus="if(this.value == '<?php echo empty($keyscode) ? '请输入搜索关键词' : $keyscode; ?>'){this.value='';}"
  848. onBlur="if(this.value == ''){this.value='<?php echo empty($keyscode) ? '请输入搜索关键词' : $keyscode; ?>';}"
  849. onKeyDown="if(event.keyCode==13){location.href='?Keys='+escape(document.getElementById('keys').value)+'<?php echo $urlStr; ?>'}" />
  850. <input type="button" id="searchgo" class="searchgo" value="go"
  851. onClick="location.href='?Keys='+escape(document.getElementById('keys').value)+'<?php echo $urlStr; ?>'" />
  852. </div>
  853. </div>
  854. <table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
  855. <thead>
  856. <tr>
  857. <th width="4%"><input type="checkbox" name="chkall" id="chkall" onClick="chkboxall(this,'chkbox')" /></th>
  858. <th width="6%">序号</th>
  859. <th width="20%">客户编码</th>
  860. <th width="10%">联系人</th>
  861. <th width="10%">国家地区</th>
  862. <th width="7.5%">来源</th>
  863. <th width="7.5%">是否成交</th>
  864. <th width="10%">业务员</th>
  865. <th width="10%">操作</th>
  866. </tr>
  867. </thead>
  868. <tbody>
  869. <?php
  870. if ($result->num_rows > 0) {
  871. $pageSize = 18;
  872. $totalPages = ceil($result->num_rows / $pageSize);
  873. if (empty($page)) $page = 1;
  874. if ($page == 'end') $page = $totalPages;
  875. if (!is_numeric($page) || $page < 1) $page = 1;
  876. $page = (int)$page;
  877. if ($page > $totalPages) $page = $totalPages;
  878. $offset = ($page - 1) * $pageSize;
  879. $sql .= " LIMIT $offset, $pageSize";
  880. $result = $conn->query($sql);
  881. $tempNum = $pageSize * ($page - 1);
  882. while ($row = $result->fetch_assoc()) {
  883. $tempNum++;
  884. ?>
  885. <tr onMouseOver="this.style.background='#F7FCFF'" onMouseOut="this.style.background='#FFFFFF'">
  886. <td align="center"><input type="checkbox" name="chkbox" value="<?php echo $row['id'] ?? ''; ?>" /></td>
  887. <td align="center"><?php echo $tempNum; ?></td>
  888. <td align="center" class="code" data-id="<?php echo $row['id'] ?? ''; ?>">
  889. <?php
  890. echo $row['cs_code'] ?? ''; ?>
  891. <?php if(($row['cs_claimFrom'] ?? 0) > 0): ?>
  892. <img src="../images/yijiao.png" class="handover">
  893. <?php endif; ?>
  894. </td>
  895. <td align="center"><?php echo $row['cs_name'] ?? ''; ?></td>
  896. <td align="center">
  897. <?php
  898. $countryId = intval($row['cs_country'] ?? 0);
  899. $sql = "SELECT countryName FROM country WHERE id = " . $countryId;
  900. $countryResult = $conn->query($sql);
  901. if ($countryRow = $countryResult->fetch_assoc()) {
  902. echo htmlspecialchars($countryRow['countryName']);
  903. } else {
  904. echo "未选择";
  905. }
  906. ?>
  907. </td>
  908. <td align="center">
  909. <?php
  910. $fromId = intval($row['cs_from'] ?? 0);
  911. $sql = "SELECT ch_name FROM qudao WHERE id = " . $fromId;
  912. $qudaoResult = $conn->query($sql);
  913. if ($qudaoRow = $qudaoResult->fetch_assoc()) {
  914. echo htmlspecialchars($qudaoRow['ch_name']);
  915. } else {
  916. echo "未选择";
  917. }
  918. ?>
  919. </td>
  920. <td align="center">
  921. <?php
  922. $cs_deal = intval($row['cs_deal'] ?? 0);
  923. if ($cs_deal == 3) {
  924. echo "<span style='color:red;font-size:10px;'>" . htmlspecialchars($row['cs_dealdate'] ?? '') . "成交</span>";
  925. } elseif ($cs_deal == 2) {
  926. echo "明确需求";
  927. } elseif ($cs_deal == 1) {
  928. echo "背景调查";
  929. } else {
  930. echo "无响应";
  931. }
  932. ?>
  933. </td>
  934. <td align="center">
  935. <?php
  936. $belongId = intval($row['cs_belong'] ?? 0);
  937. $sql = "SELECT em_user FROM employee WHERE id = " . $belongId;
  938. $empResult = $conn->query($sql);
  939. if ($empRow = $empResult->fetch_assoc()) {
  940. echo htmlspecialchars($empRow['em_user']);
  941. } else {
  942. echo "未选择";
  943. }
  944. ?>
  945. </td>
  946. <td align="center">
  947. <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>
  948. </td>
  949. </tr>
  950. <tr class="detail_panel code<?php echo $row['id'] ?? ''; ?>__panel">
  951. <td colspan="2"></td>
  952. <td colspan="7" class="cs_detail">
  953. <ul>
  954. <li class="cs_detail_addtime">录入时间:<?php echo htmlspecialchars($row['cs_addtime'] ?? ''); ?></li>
  955. <li class="cs_detail_addtime">更新时间:<?php echo htmlspecialchars($row['cs_updatetime'] ?? ''); ?></li>
  956. <li class="cs_detail_addtime">
  957. 流转记录:
  958. <?php
  959. $chain = $row['cs_chain'] ?? '';
  960. if(!empty($chain)) {
  961. $chain_array = explode(',', $chain);
  962. $chain_ids = array_filter(array_map('intval', $chain_array));
  963. if(!empty($chain_ids)) {
  964. $chain_ids_str = implode(',', $chain_ids);
  965. $sql = "SELECT em_user FROM employee WHERE id IN (" . $chain_ids_str . ")";
  966. $chainResult = $conn->query($sql);
  967. $chain_users = [];
  968. while($chainRow = $chainResult->fetch_assoc()) {
  969. $chain_users[] = htmlspecialchars($chainRow['em_user']);
  970. }
  971. echo implode(' > ', $chain_users);
  972. }
  973. }
  974. ?>
  975. </li>
  976. <?php if(!empty($row['cs_tel'] ?? '')): ?>
  977. <li class="tel"><?php echo htmlspecialchars($row['cs_tel']); ?></li>
  978. <?php endif; ?>
  979. <?php if(!empty($row['cs_email'] ?? '')): ?>
  980. <li class="mail"><?php echo htmlspecialchars($row['cs_email']); ?></li>
  981. <?php endif; ?>
  982. <?php if(!empty($row['cs_whatsapp'] ?? '')): ?>
  983. <li class="whatsapp"><?php echo htmlspecialchars($row['cs_whatsapp']); ?></li>
  984. <?php endif; ?>
  985. <?php if(!empty($row['cs_wechat'] ?? '')): ?>
  986. <li class="wechat"><?php echo htmlspecialchars($row['cs_wechat']); ?></li>
  987. <?php endif; ?>
  988. <?php if(!empty($row['cs_linkedin'] ?? '')): ?>
  989. <li class="linkedin"><?php echo htmlspecialchars($row['cs_linkedin']); ?></li>
  990. <?php endif; ?>
  991. <?php if(!empty($row['cs_facebook'] ?? '')): ?>
  992. <li class="facebook"><?php echo htmlspecialchars($row['cs_facebook']); ?></li>
  993. <?php endif; ?>
  994. <?php if(!empty($row['cs_alibaba'] ?? '')): ?>
  995. <li class="alibaba"><?php echo htmlspecialchars($row['cs_alibaba']); ?></li>
  996. <?php endif; ?>
  997. <?php if(!empty($row['cs_address'] ?? '')): ?>
  998. <li class="address"><?php echo htmlspecialchars($row['cs_address']); ?></li>
  999. <?php endif; ?>
  1000. </ul>
  1001. <div class="cs_detail_note"><?php echo htmlspecialchars($row['cs_note'] ?? ''); ?></div>
  1002. </td>
  1003. </tr>
  1004. <?php
  1005. }
  1006. } else {
  1007. if (empty($keys)) {
  1008. ?>
  1009. <tr>
  1010. <td align="center" colspan="9">Sorry,当前暂无信息</td>
  1011. </tr>
  1012. <?php
  1013. } else {
  1014. ?>
  1015. <tr>
  1016. <td align="center" colspan="9"><a href="?">Sorry,没有找到"<?php echo $keyscode; ?>"相关的信息,点击返回</a></td>
  1017. </tr>
  1018. <?php
  1019. }
  1020. }
  1021. ?>
  1022. </tbody>
  1023. <tfoot>
  1024. <tr>
  1025. <td colspan="9">
  1026. <div class="showpagebox">
  1027. <?php
  1028. if ($totalPages > 1) {
  1029. $pageName = "?Keys=$keys&Ord=$ord$urlStr&";
  1030. $pageLen = 3;
  1031. if ($page > 1) {
  1032. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  1033. echo "<a href=\"{$pageName}Page=" . ($page-1) . "\">上一页</a>";
  1034. }
  1035. if ($pageLen * 2 + 1 >= $totalPages) {
  1036. $startPage = 1;
  1037. $endPage = $totalPages;
  1038. } else {
  1039. if ($page <= $pageLen + 1) {
  1040. $startPage = 1;
  1041. $endPage = $pageLen * 2 + 1;
  1042. } else {
  1043. $startPage = $page - $pageLen;
  1044. $endPage = $page + $pageLen;
  1045. }
  1046. if ($page + $pageLen > $totalPages) {
  1047. $startPage = $totalPages - $pageLen * 2;
  1048. $endPage = $totalPages;
  1049. }
  1050. }
  1051. for ($i = $startPage; $i <= $endPage; $i++) {
  1052. if ($i == $page) {
  1053. echo "<a class=\"current\">$i</a>";
  1054. } else {
  1055. echo "<a href=\"{$pageName}Page=$i\">$i</a>";
  1056. }
  1057. }
  1058. if ($page < $totalPages) {
  1059. if ($totalPages - $page > $pageLen) {
  1060. echo "<a href=\"{$pageName}Page=$totalPages\">...$totalPages</a>";
  1061. }
  1062. echo "<a href=\"{$pageName}Page=" . ($page+1) . "\">下一页</a>";
  1063. echo "<a href=\"{$pageName}Page=$totalPages\">尾页</a>";
  1064. }
  1065. echo "<input type=\"text\" id=\"Pagego\" value=\"$page\"
  1066. onFocus=\"if(this.value == '$page'){this.value='';}\"
  1067. onBlur=\"if(this.value == ''){this.value='$page';}\"
  1068. onKeyUp=\"this.value=this.value.replace(/\D/g,'')\"
  1069. onKeyDown=\"if(event.keyCode==13){location.href='{$pageName}Page='+document.getElementById('Pagego').value}\" />";
  1070. }
  1071. ?>
  1072. </div>
  1073. <div class="postchkbox">
  1074. <select id="chkact" name="chkact">
  1075. <option value="1">显示</option>
  1076. <option value="0">隐藏</option>
  1077. <option value="-1">删除</option>
  1078. </select>
  1079. <input type="button" value="执行" onClick="postchk(1)" class="btn1" />
  1080. <input type="button" value="新增" onClick="location.href='?act=add'" class="btn1" />
  1081. </div>
  1082. </td>
  1083. </tr>
  1084. </tfoot>
  1085. </table>
  1086. </form>
  1087. </div>
  1088. </body>
  1089. </html>
  1090. <?php
  1091. $conn->close();
  1092. ?>