tag.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. require_once 'conn.php';
  3. checkLogin();
  4. $act = $_GET['act'] ?? '';
  5. $tagName = $_GET['tagName'] ?? '';
  6. if (empty($tagName)) {
  7. header('Location: customers.php');
  8. exit;
  9. }
  10. if ($act == 'postchk') {
  11. $keys = urlencode($_GET['Keys'] ?? '');
  12. $chkact = str_replace('t', '', $_POST['chkact'] ?? '');
  13. if (isset($_POST['chkbox'])) {
  14. $sqlStr = "(" . implode(',', array_map('intval', (array)$_POST['chkbox'])) . ")";
  15. $updateStr = "UPDATE Customer SET
  16. cs_updatetime='" . date('Y-m-d H:i:s') . "',
  17. cs_code=REPLACE(cs_code, '-', '/' + (SELECT em_code FROM employee WHERE id=" . (int)$chkact . ") + '-'),
  18. cs_belong=" . (int)$chkact . ",
  19. cs_chain=CONCAT(cs_chain,'," . (int)$chkact . "')
  20. WHERE id IN " . $sqlStr;
  21. $deleteTag = "DELETE FROM tagTable WHERE customerId IN " . $sqlStr;
  22. $conn->query($updateStr);
  23. $conn->query($deleteTag);
  24. }
  25. header('Location: tag.php?tagName=' . urlencode($tagName));
  26. exit;
  27. }
  28. // Get all tags for the current employee
  29. $tagStr = '';
  30. $result = $conn->query("SELECT DISTINCT tagName FROM tagTable WHERE employeeId=" . $_SESSION['employee_id']);
  31. while ($row = $result->fetch_assoc()) {
  32. $tagStr .= "<span>" . htmlspecialchars($row['tagName']) . "</span>,";
  33. }
  34. ?>
  35. <!DOCTYPE html>
  36. <html xmlns="http://www.w3.org/1999/xhtml">
  37. <head>
  38. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  39. <title>管理区域</title>
  40. <link rel="stylesheet" href="css/common.css" type="text/css" />
  41. <link rel="stylesheet" href="css/alert.css" type="text/css" />
  42. <script src="system/js/jquery-1.7.2.min.js"></script>
  43. <script src="js/js.js"></script>
  44. </head>
  45. <body class="clear">
  46. <?php require_once 'panel.php'; ?>
  47. <div id="man_zone">
  48. <div class="fastSelect clear">
  49. <H1 class="taghead" contenteditable="true" data-originaltag="<?= htmlspecialchars($tagName) ?>" data-em="<?= $_SESSION['employee_id'] ?>"><?= htmlspecialchars($tagName) ?></H1>
  50. </div>
  51. <form id="form1" method="post" action="?act=postchk&tagName=<?= urlencode($tagName) ?>" onsubmit="return false">
  52. <div width="100%" border="0" cellpadding="3" cellspacing="1" class="table2">
  53. <div class="theader">
  54. <div class="col1"><input type="checkbox" name="chkall" id="chkall" onclick="chkboxall(this,'chkbox')"></div>
  55. <div class="col2">序号</div>
  56. <div class="col3">客户编号</div>
  57. <div class="col4">渠道来源</div>
  58. <div class="col5">区域</div>
  59. <div class="col7">跟进阶段</div>
  60. <div class="col8">录入时间</div>
  61. <div class="col10">操作</div>
  62. </div>
  63. <?php
  64. $sqlStr = "SELECT id, cs_code, cs_from, cs_country, cs_type, cs_deal, cs_addtime, cs_tel, cs_email,
  65. cs_whatsapp, cs_wechat, cs_linkedin, cs_facebook, cs_alibaba, cs_note
  66. FROM customer
  67. WHERE cs_belong=" . $_SESSION['employee_id'] . "
  68. AND id IN (SELECT customerId FROM tagTable WHERE tagName='" . $conn->real_escape_string($tagName) . "')";
  69. $result = $conn->query($sqlStr);
  70. $tempNum = 0;
  71. while ($row = $result->fetch_assoc()) {
  72. $tempNum++;
  73. ?>
  74. <div class="tline">
  75. <div class="col1" align="center"><input type="checkbox" name="chkbox[]" value="<?= $row['id'] ?>"></div>
  76. <div class="col2"><?= $tempNum ?></div>
  77. <div class="col3 slidepanel"><?= htmlspecialchars($row['cs_code']) ?></div>
  78. <div class="col4">
  79. <?php
  80. $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
  81. echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialchars($qudaoRow['ch_name']) : '未填写';
  82. ?>
  83. </div>
  84. <div class="col5">
  85. <?php
  86. $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
  87. echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialchars($countryRow['countryName']) : '未填写';
  88. ?>
  89. </div>
  90. <div class="col7">
  91. <?php
  92. if ($row['cs_deal'] == 3) {
  93. echo "<span style='color:red;'>成交</span>";
  94. } elseif ($row['cs_deal'] == 2) {
  95. echo "明确需求";
  96. } elseif ($row['cs_deal'] == 1) {
  97. echo "背景调查";
  98. } else {
  99. echo "无响应";
  100. }
  101. ?>
  102. </div>
  103. <div class="col8"><?= $row['cs_addtime'] ?></div>
  104. <div class="col10"><a href="customerEdit.php?id=<?= $row['id'] ?>" class="ico_edit ico">修改</a></div>
  105. </div>
  106. <div class="notepanel clear">
  107. <div class="noteItem">联系方式</div>
  108. <div class="lx">
  109. <div class="tel"><?= htmlspecialchars($row['cs_tel']) ?></div>
  110. <div class="mail"><a href="mailto:<?= htmlspecialchars($row['cs_email']) ?>"><?= htmlspecialchars($row['cs_email']) ?></a></div>
  111. <div class="whatsapp"><?= htmlspecialchars($row['cs_whatsapp']) ?></div>
  112. <div class="wechat"><?= htmlspecialchars($row['cs_wechat']) ?></div>
  113. <div class="linkedin"><?= htmlspecialchars($row['cs_linkedin']) ?></div>
  114. <div class="facebook"><?= htmlspecialchars($row['cs_facebook']) ?></div>
  115. <div class="alibaba"><?= htmlspecialchars($row['cs_alibaba']) ?></div>
  116. </div>
  117. <div class="noteItem2">备注</div>
  118. <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
  119. <div class="coltag mytag" data-id="<?= $row['id'] ?>" data-em="<?= $_SESSION['employee_id'] ?>">
  120. <?php
  121. $tagStr1 = $tagStr;
  122. $tagResult = $conn->query("SELECT tagName FROM tagTable WHERE customerId=" . $row['id']);
  123. while ($tagRow = $tagResult->fetch_assoc()) {
  124. $tagStr1 = str_replace(
  125. "<span>" . htmlspecialchars($tagRow['tagName']) . "</span>",
  126. "<span class=\"active\">" . htmlspecialchars($tagRow['tagName']) . "</span>",
  127. $tagStr1
  128. );
  129. }
  130. echo $tagStr1;
  131. ?>
  132. </div>
  133. </div>
  134. <?php
  135. }
  136. ?>
  137. <div colspan="9">
  138. <div class="showpagebox">
  139. </div>
  140. <div class="postchkbox">
  141. <select id="chkact" name="chkact">
  142. <?php
  143. $result = $conn->query("SELECT id, em_code, em_user FROM employee ORDER BY em_code ASC");
  144. while ($row = $result->fetch_assoc()) {
  145. echo "<option value=\"t{$row['id']}\">转给" . htmlspecialchars($row['em_user']) . "(" . htmlspecialchars($row['em_code']) . ")</option>";
  146. }
  147. ?>
  148. </select>
  149. <input type="button" value="执行" onclick="postchk(1)" class="btn1">
  150. </div>
  151. </div>
  152. </div>
  153. </form>
  154. </div>
  155. </body>
  156. </html>