tag.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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>" . htmlspecialcharsFix($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. <style>
  45. body {
  46. margin: 0;
  47. padding: 20px;
  48. background: #fff;
  49. }
  50. #man_zone {
  51. margin-left: 0;
  52. }
  53. </style>
  54. </head>
  55. <body class="clear">
  56. <?php // require_once 'panel.php'; ?>
  57. <div id="man_zone">
  58. <div class="fastSelect clear">
  59. <H1 class="taghead" contenteditable="true" data-originaltag="<?= htmlspecialcharsFix($tagName) ?>" data-em="<?= $_SESSION['employee_id'] ?>"><?= htmlspecialcharsFix($tagName) ?></H1>
  60. </div>
  61. <form id="form1" method="post" action="?act=postchk&tagName=<?= urlencode($tagName) ?>" onsubmit="return false">
  62. <div width="100%" border="0" cellpadding="3" cellspacing="1" class="table2">
  63. <div class="theader">
  64. <div class="col1"><input type="checkbox" name="chkall" id="chkall" onclick="chkboxall(this,'chkbox')"></div>
  65. <div class="col2">序号</div>
  66. <div class="col3">客户编号</div>
  67. <div class="col4">渠道来源</div>
  68. <div class="col5">区域</div>
  69. <div class="col7">跟进阶段</div>
  70. <div class="col8">录入时间</div>
  71. <div class="col10">操作</div>
  72. </div>
  73. <?php
  74. $sqlStr = "SELECT id, cs_code, cs_from, cs_country, cs_type, cs_deal, cs_addtime, cs_tel, cs_email,
  75. cs_whatsapp, cs_wechat, cs_linkedin, cs_facebook, cs_alibaba, cs_note
  76. FROM customer
  77. WHERE cs_belong=" . $_SESSION['employee_id'] . "
  78. AND id IN (SELECT customerId FROM tagtable WHERE tagName='" . $conn->real_escape_string($tagName) . "')";
  79. $result = $conn->query($sqlStr);
  80. $tempNum = 0;
  81. while ($row = $result->fetch_assoc()) {
  82. $tempNum++;
  83. ?>
  84. <div class="tline">
  85. <div class="col1" align="center"><input type="checkbox" name="chkbox[]" value="<?= $row['id'] ?>"></div>
  86. <div class="col2"><?= $tempNum ?></div>
  87. <div class="col3 slidepanel"><?= htmlspecialcharsFix($row['cs_code']) ?></div>
  88. <div class="col4">
  89. <?php
  90. $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
  91. echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未填写';
  92. ?>
  93. </div>
  94. <div class="col5">
  95. <?php
  96. $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
  97. echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未填写';
  98. ?>
  99. </div>
  100. <div class="col7">
  101. <?php
  102. if ($row['cs_deal'] == 3) {
  103. echo "<span style='color:red;'>成交</span>";
  104. } elseif ($row['cs_deal'] == 2) {
  105. echo "明确需求";
  106. } elseif ($row['cs_deal'] == 1) {
  107. echo "背景调查";
  108. } else {
  109. echo "无响应";
  110. }
  111. ?>
  112. </div>
  113. <div class="col8"><?= $row['cs_addtime'] ?></div>
  114. <div class="col10"><a href="customerEdit.php?id=<?= $row['id'] ?>" class="ico_edit ico">修改</a></div>
  115. </div>
  116. <div class="notepanel clear">
  117. <div class="noteItem">联系方式</div>
  118. <div class="lx">
  119. <div class="tel"><?= htmlspecialcharsFix($row['cs_tel']) ?></div>
  120. <div class="mail"><a href="mailto:<?= htmlspecialcharsFix($row['cs_email']) ?>"><?= htmlspecialcharsFix($row['cs_email']) ?></a></div>
  121. <div class="whatsapp"><?= htmlspecialcharsFix($row['cs_whatsapp']) ?></div>
  122. <div class="wechat"><?= htmlspecialcharsFix($row['cs_wechat']) ?></div>
  123. <div class="linkedin"><?= htmlspecialcharsFix($row['cs_linkedin']) ?></div>
  124. <div class="facebook"><?= htmlspecialcharsFix($row['cs_facebook']) ?></div>
  125. <div class="alibaba"><?= htmlspecialcharsFix($row['cs_alibaba']) ?></div>
  126. </div>
  127. <div class="noteItem2">备注</div>
  128. <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
  129. <div class="coltag mytag" data-id="<?= $row['id'] ?>" data-em="<?= $_SESSION['employee_id'] ?>">
  130. <?php
  131. $tagStr1 = $tagStr;
  132. $tagResult = $conn->query("SELECT tagName FROM tagtable WHERE customerId=" . $row['id']);
  133. while ($tagRow = $tagResult->fetch_assoc()) {
  134. $tagStr1 = str_replace(
  135. "<span>" . htmlspecialcharsFix($tagRow['tagName']) . "</span>",
  136. "<span class=\"active\">" . htmlspecialcharsFix($tagRow['tagName']) . "</span>",
  137. $tagStr1
  138. );
  139. }
  140. echo $tagStr1;
  141. ?>
  142. </div>
  143. </div>
  144. <?php
  145. }
  146. ?>
  147. <div colspan="9">
  148. <div class="showpagebox">
  149. </div>
  150. <div class="postchkbox">
  151. <select id="chkact" name="chkact">
  152. <?php
  153. $result = $conn->query("SELECT id, em_code, em_user FROM employee ORDER BY em_code ASC");
  154. while ($row = $result->fetch_assoc()) {
  155. echo "<option value=\"t{$row['id']}\">转给" . htmlspecialcharsFix($row['em_user']) . "(" . htmlspecialcharsFix($row['em_code']) . ")</option>";
  156. }
  157. ?>
  158. </select>
  159. <input type="button" value="执行" onclick="postchk(1)" class="btn1">
  160. </div>
  161. </div>
  162. </div>
  163. </form>
  164. </div>
  165. </body>
  166. </html>